Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333285

Summary: Bogus syntax error for non-type template parameter starting with keyword 'typename' or 'class'
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: 8.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
testcase + fix mschorn.eclipse: iplog-

Description Nathan Ridge CLA 2010-12-28 17:58:32 EST
The parser marks as a syntax error the following valid code:

template <typename T>
struct A
{
    typedef Ttype;
};

template <typename T>
struct X
{
    template <typename A<T>::type x>  // SYNTAX ERROR HERE
    struct Y
    {
        
    };
};

Notice that in spite of the presence of "typename", the template paramter of Y is a non-type template parameter. The type of the template parameter is "typename A<T>::type", and the name of the template parameter is "x". The "typename" is necessary because A<T> is a dependent type.
Comment 1 Nathan Ridge CLA 2010-12-28 17:59:49 EST
Apologies, there is a typo inside struct A: that should be "typedef T type;", with a space.
Comment 2 Markus Schorn CLA 2011-01-07 06:12:21 EST
Created attachment 186259 [details]
testcase + fix

Thanks for the example!
Comment 3 Markus Schorn CLA 2011-01-07 06:18:01 EST
Fixed in 8.0 > 20110107.