Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367607 - Parser error involving templates and inheritance
Summary: Parser error involving templates and inheritance
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-28 13:59 EST by Nathan Ridge CLA
Modified: 2012-02-23 11:33 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.