]> granicus.if.org Git - clang/commitdiff
fix a crash on invalid I found when working on something unrelated.
authorChris Lattner <sabre@nondot.org>
Mon, 7 Dec 2009 00:48:47 +0000 (00:48 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 7 Dec 2009 00:48:47 +0000 (00:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90729 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/Parser.cpp
test/Parser/cxx-friend.cpp

index ca425e8b0528d9ed1e07f42d2aa42147b6d3d82b..20e5c589d710dd84668b5eebbb34c2eabf759902 100644 (file)
@@ -1030,7 +1030,9 @@ bool Parser::TryAnnotateCXXScopeToken(bool EnteringContext) {
 
   CXXScopeSpec SS;
   if (!ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, EnteringContext))
-    return Tok.is(tok::annot_template_id);
+    // If the token left behind is not an identifier, we either had an error or
+    // successfully turned it into an annotation token.
+    return Tok.isNot(tok::identifier);
 
   // Push the current token back into the token stream (or revert it if it is
   // cached) and use an annotation scope token for current token.
index 14b31af761d3df88e6082ef01f10f7a9c1155681..6505ad0f6f761c8f622c6b8ab11e35c6d3d05145 100644 (file)
@@ -30,3 +30,11 @@ class B {
   void f(A *a) { a->f(); }
 };
 
+
+
+
+
+template <typename t1, typename t2> class some_template;
+friend   // expected-error {{'friend' used outside of class}}
+some_template<foo, bar>&  // expected-error {{use of undeclared identifier 'foo'}}
+  ;  // expected-error {{expected unqualified-id}}