Fix crash-on-invalid: don't look ahead past an unknown token, it might be EOF.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 21 Jul 2015 00:23:34 +0000 (00:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 21 Jul 2015 00:23:34 +0000 (00:23 +0000)
llvm-svn: 242744

clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/cxx0x-decl.cpp

index 0fb1de9..7913890 100644 (file)
@@ -546,7 +546,8 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
   } else if (ParseUnqualifiedId(
                  SS, /*EnteringContext=*/false,
                  /*AllowDestructorName=*/true,
-                 /*AllowConstructorName=*/NextToken().isNot(tok::equal),
+                 /*AllowConstructorName=*/!(Tok.is(tok::identifier) &&
+                                            NextToken().is(tok::equal)),
                  ParsedType(), TemplateKWLoc, Name)) {
     SkipUntil(tok::semi);
     return nullptr;
index 994104f..23f46a1 100644 (file)
@@ -132,3 +132,7 @@ void NoMissingSemicolonHere(struct S
                             [3]);
 template<int ...N> void NoMissingSemicolonHereEither(struct S
                                                      ... [N]);
+
+// This must be at the end of the file; we used to look ahead past the EOF token here.
+// expected-error@+1 {{expected unqualified-id}}
+using