From: Richard Smith Date: Tue, 21 Jul 2015 00:23:34 +0000 (+0000) Subject: Fix crash-on-invalid: don't look ahead past an unknown token, it might be EOF. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce95e4dcf4f15083647ac058601ce435ac9ed1fa;p=clang Fix crash-on-invalid: don't look ahead past an unknown token, it might be EOF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242744 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 0fb1de94e8..79138900b8 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -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; diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp index 994104fc9d..23f46a1847 100644 --- a/test/Parser/cxx0x-decl.cpp +++ b/test/Parser/cxx0x-decl.cpp @@ -132,3 +132,7 @@ void NoMissingSemicolonHere(struct S [3]); template 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