r242744 - Fix crash-on-invalid: don't look ahead past an unknown token, it might be EOF.

Richard Smith richard-llvm at metafoo.co.uk
Mon Jul 20 17:23:35 PDT 2015


Author: rsmith
Date: Mon Jul 20 19:23:34 2015
New Revision: 242744

URL: http://llvm.org/viewvc/llvm-project?rev=242744&view=rev
Log:
Fix crash-on-invalid: don't look ahead past an unknown token, it might be EOF.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/cxx0x-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=242744&r1=242743&r2=242744&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Jul 20 19:23:34 2015
@@ -546,7 +546,8 @@ Decl *Parser::ParseUsingDeclaration(unsi
   } 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;

Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=242744&r1=242743&r2=242744&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Mon Jul 20 19:23:34 2015
@@ -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 at +1 {{expected unqualified-id}}
+using





More information about the cfe-commits mailing list