summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Parse/Parser.cpp4
-rw-r--r--clang/test/Parser/cxx-friend.cpp8
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index ca425e8b052..20e5c589d71 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -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.
diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
index 14b31af761d..6505ad0f6f7 100644
--- a/clang/test/Parser/cxx-friend.cpp
+++ b/clang/test/Parser/cxx-friend.cpp
@@ -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}}
OpenPOWER on IntegriCloud