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

Bug 399454

Summary: Error involving nested templates inside enclosing templates
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-indexerAssignee: Nathan Ridge <zeratul976>
Status: VERIFIED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse.sprigogin, malaperle
Version: Next   
Target Milestone: 8.2.1   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=407497
Whiteboard:

Description Nathan Ridge CLA 2013-01-29 23:30:22 EST
More specifically, this error concerns nested templates inside enclosing templates where the nested template has a template parameter whose default value uses one of the enclosing template's template parameters:


struct Cat { int meow(); };

template <typename T>
struct enclosing
{
    template <typename U = T>
    struct nested
    {
        typedef U type;
    };
};

int main()
{
    enclosing<Cat>::nested<>::type t;
    t.meow();  // ERROR HERE: 'meow' could not be resolved
}
Comment 1 Nathan Ridge CLA 2013-07-09 23:34:36 EDT
A similar issue came up in bug 407497, where the nested template's template parameter's *type* (it's a non-type parameter) depends on the enclosing template's template parameter.

The fix for both is to specialize the nested template's template parameter with the enclosing template's parameter map, as Markus suggests in his "mstodo" in CPPClassTemplateSpecialization.getTemplateParameters().

As I mentioned in bug 407497, I believe this requires introducing bindings for template parameter specializations.
Comment 2 Nathan Ridge CLA 2013-07-13 20:02:42 EDT
Patch (also fixes bug 407497): https://git.eclipse.org/r/#/c/14533/
Comment 3 Marc-André Laperle CLA 2013-07-23 00:01:50 EDT
Fixed in 8.2.1 and master.
Comment 4 Marc-André Laperle CLA 2013-08-31 00:28:30 EDT
Verified in 20130821-2252 (RC1).