| Summary: | Bogus syntax error for non-type template parameter starting with keyword 'typename' or 'class' | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Nathan Ridge <zeratul976> | ||||
| Component: | cdt-parser | Assignee: | 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: |
|
||||||
Apologies, there is a typo inside struct A: that should be "typedef T type;", with a space. Created attachment 186259 [details]
testcase + fix
Thanks for the example!
Fixed in 8.0 > 20110107. *** cdt cvs genie on behalf of mschorn *** Bug 333285: Non-type template parameter with leading typename keyword. [*] GNUCPPSourceParser.java 1.245 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java?root=Tools_Project&r1=1.244&r2=1.245 [*] AST2TemplateTests.java 1.201 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java?root=Tools_Project&r1=1.200&r2=1.201 |
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.