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

Bug 367607

Summary: Parser error involving templates and inheritance
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.1.0   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2011-12-28 13:59:21 EST
For the following code:


template <typename>
struct base
{
    typedef int type;
};

template <typename A, typename B>
struct derived;

template <typename B>
struct derived<int, B> : public base<B>
{
    typedef typename derived::type type;  // ERROR HERE
};


The parser gives an error "Type 'derived::type' could not be resolved" at the indicated line. The error goes away if I provide a definition for the main "derived" template.

I believe this is valid code, because inside the "derived<int, B>" specialization, "derived" is short for "derived<int, B>".

The code compiles with GCC, clang, and Comeau.
Comment 1 Markus Schorn CLA 2012-01-05 03:30:10 EST
You are right, the parser fails to detect the shorthand notation within the qualified name. Added testcase and fix.