[cfe-commits] r67685 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaTemplate/class-template-id.cpp

Douglas Gregor dgregor at apple.com
Wed Mar 25 08:40:01 PDT 2009


Author: dgregor
Date: Wed Mar 25 10:40:00 2009
New Revision: 67685

URL: http://llvm.org/viewvc/llvm-project?rev=67685&view=rev
Log:
Fix parsing of template classes prefixed by nested-name-specifiers

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/SemaTemplate/class-template-id.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=67685&r1=67684&r2=67685&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Mar 25 10:40:00 2009
@@ -497,7 +497,20 @@
         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<TemplateIdAnnotation *>(Next.getAnnotationValue())
+          ->Kind == TNK_Class_template) {
+        // We have a qualified template-id, e.g., N::A<int>
+        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 @@
           GetLookAheadToken(2).is(tok::l_paren))
         goto DoneWithDeclSpec;
 
-      Token Next = NextToken();
       TypeTy *TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
                                             Next.getLocation(), CurScope, &SS);
 

Modified: cfe/trunk/test/SemaTemplate/class-template-id.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-id.cpp?rev=67685&r1=67684&r2=67685&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-id.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-id.cpp Wed Mar 25 10:40:00 2009
@@ -28,3 +28,11 @@
 }
 
 typedef B<5> B5;
+
+
+namespace N {
+  template<typename T> struct C {};
+}
+
+N::C<int> c1;
+typedef N::C<float> c2;





More information about the cfe-commits mailing list