]> granicus.if.org Git - clang/commitdiff
push the call in isCXXDeclarationSpecifier to TryAnnotateTypeOrScopeToken
authorChris Lattner <sabre@nondot.org>
Sun, 4 Jan 2009 23:33:56 +0000 (23:33 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 4 Jan 2009 23:33:56 +0000 (23:33 +0000)
down into the two cases that it can possibly affect.  This avoids calls
to it that obviously can't do anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61651 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseTentative.cpp

index f352efa87262ed600a43c54d221ea8ddc68d24bf..a76c5c66f2014b152321c6b5f2893972f30b4dc6 100644 (file)
@@ -558,10 +558,27 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
 /// [GNU]     restrict
 ///
 Parser::TPResult Parser::isCXXDeclarationSpecifier() {
-  // Annotate typenames and C++ scope specifiers.
-  TryAnnotateTypeOrScopeToken();
-
   switch (Tok.getKind()) {
+  case tok::identifier:   // foo::bar
+    // Annotate typenames and C++ scope specifiers.  If we get one, just
+    // recurse to handle whatever we get.
+    if (TryAnnotateTypeOrScopeToken())
+      return isCXXDeclarationSpecifier();
+    // Otherwise, not a typename.
+    return TPResult::False();
+
+  case tok::coloncolon:   // ::foo::bar
+      if (NextToken().is(tok::kw_new) ||    // ::new
+          NextToken().is(tok::kw_delete))   // ::delete
+        return TPResult::False();
+      
+    // Annotate typenames and C++ scope specifiers.  If we get one, just
+    // recurse to handle whatever we get.
+    if (TryAnnotateTypeOrScopeToken())
+      return isCXXDeclarationSpecifier();
+    // Otherwise, not a typename.
+    return TPResult::False();
+      
     // decl-specifier:
     //   storage-class-specifier
     //   type-specifier