r256080 - Fix crash-on-invalid if a :: is followed by two or more open parentheses (and then something else).
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 18 18:40:19 PST 2015
Author: rsmith
Date: Fri Dec 18 20:40:19 2015
New Revision: 256080
URL: http://llvm.org/viewvc/llvm-project?rev=256080&view=rev
Log:
Fix crash-on-invalid if a :: is followed by two or more open parentheses (and then something else).
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/colon-colon-parentheses.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=256080&r1=256079&r2=256080&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Dec 18 20:40:19 2015
@@ -5198,6 +5198,15 @@ void Parser::ParseDirectDeclarator(Decla
}
goto PastIdentifier;
}
+
+ if (D.getCXXScopeSpec().isNotEmpty()) {
+ // We have a scope specifier but no following unqualified-id.
+ Diag(PP.getLocForEndOfToken(D.getCXXScopeSpec().getEndLoc()),
+ diag::err_expected_unqualified_id)
+ << /*C++*/1;
+ D.SetIdentifier(nullptr, Tok.getLocation());
+ goto PastIdentifier;
+ }
} else if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
assert(!getLangOpts().CPlusPlus &&
"There's a C++-specific check for tok::identifier above");
Modified: cfe/trunk/test/Parser/colon-colon-parentheses.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/colon-colon-parentheses.cpp?rev=256080&r1=256079&r2=256080&view=diff
==============================================================================
--- cfe/trunk/test/Parser/colon-colon-parentheses.cpp (original)
+++ cfe/trunk/test/Parser/colon-colon-parentheses.cpp Fri Dec 18 20:40:19 2015
@@ -22,9 +22,9 @@ void foo() {
}
#ifdef PR21815
-// expected-error at +4{{C++ requires a type specifier for all declarations}}
-// expected-error at +3{{expected unqualified-id}}
-// expected-error at +3{{expected expression}}
-// expected-error at +1{{expected ';' after top level declarator}}
-a (::(
+// expected-error at +2{{C++ requires a type specifier for all declarations}}
+// expected-error at +1{{expected unqualified-id}}
+a (::( ));
+
+::((c )); // expected-error{{expected unqualified-id}}
#endif
More information about the cfe-commits
mailing list