From: Douglas Gregor Date: Wed, 25 Mar 2009 15:40:00 +0000 (+0000) Subject: Fix parsing of template classes prefixed by nested-name-specifiers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9135c72fd17bf313072fa12cfe66eb2437ef8e9d;p=clang Fix parsing of template classes prefixed by nested-name-specifiers git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67685 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 81685eb8ca..a6e7d52fc1 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -497,7 +497,20 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, goto DoneWithDeclSpec; // We are looking for a qualified typename. - if (NextToken().isNot(tok::identifier)) + Token Next = NextToken(); + if (Next.is(tok::annot_template_id) && + static_cast(Next.getAnnotationValue()) + ->Kind == TNK_Class_template) { + // We have a qualified template-id, e.g., N::A + CXXScopeSpec SS; + ParseOptionalCXXScopeSpecifier(SS); + assert(Tok.is(tok::annot_template_id) && + "ParseOptionalCXXScopeSpecifier not working"); + AnnotateTemplateIdTokenAsType(&SS); + continue; + } + + if (Next.isNot(tok::identifier)) goto DoneWithDeclSpec; CXXScopeSpec SS; @@ -512,7 +525,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, GetLookAheadToken(2).is(tok::l_paren)) goto DoneWithDeclSpec; - Token Next = NextToken(); TypeTy *TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(), Next.getLocation(), CurScope, &SS); diff --git a/test/SemaTemplate/class-template-id.cpp b/test/SemaTemplate/class-template-id.cpp index e0e1cba9a5..e74a6f8dcc 100644 --- a/test/SemaTemplate/class-template-id.cpp +++ b/test/SemaTemplate/class-template-id.cpp @@ -28,3 +28,11 @@ B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) { } typedef B<5> B5; + + +namespace N { + template struct C {}; +} + +N::C c1; +typedef N::C c2;