summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-02-26 08:45:28 +0000
committerJohn McCall <rjmccall@apple.com>2010-02-26 08:45:28 +0000
commit1f476a1783d95d9b53b10f763789e8afeded42f3 (patch)
treeef4171febd99b0f182fd41f0569b0f83d1b006bc /clang/lib/Parse/ParseTentative.cpp
parent663f658d87961061a191611ce4a8ec3f32df296f (diff)
downloadbcm5719-llvm-1f476a1783d95d9b53b10f763789e8afeded42f3.tar.gz
bcm5719-llvm-1f476a1783d95d9b53b10f763789e8afeded42f3.zip
Fix an assertion-on-error during tentative constructor parsing by
propagating error conditions out of the various annotate-me-a-snowflake routines. Generally (but not universally) removes redundant diagnostics as well as, you know, not crashing on bad code. On the other hand, I have just signed myself up to fix fiddly parser errors for the next week. Again. llvm-svn: 97221
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r--clang/lib/Parse/ParseTentative.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 6251a2f3675..516a9a620b6 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -491,7 +491,8 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract,
while (1) {
if (Tok.is(tok::coloncolon) || Tok.is(tok::identifier))
- TryAnnotateCXXScopeToken(true);
+ if (TryAnnotateCXXScopeToken(true))
+ return TPResult::Error();
if (Tok.is(tok::star) || Tok.is(tok::amp) || Tok.is(tok::caret) ||
(Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
@@ -681,9 +682,10 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
- return isCXXDeclarationSpecifier();
- // Otherwise, not a typename.
- return TPResult::False();
+ return TPResult::Error();
+ if (Tok.is(tok::identifier))
+ return TPResult::False();
+ return isCXXDeclarationSpecifier();
case tok::coloncolon: { // ::foo::bar
const Token &Next = NextToken();
@@ -694,9 +696,8 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
- return isCXXDeclarationSpecifier();
- // Otherwise, not a typename.
- return TPResult::False();
+ return TPResult::Error();
+ return isCXXDeclarationSpecifier();
}
// decl-specifier:
@@ -762,7 +763,9 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
case tok::annot_cxxscope: // foo::bar or ::foo::bar, but already parsed
// We've already annotated a scope; try to annotate a type.
- if (!(TryAnnotateTypeOrScopeToken() && Tok.is(tok::annot_typename)))
+ if (TryAnnotateTypeOrScopeToken())
+ return TPResult::Error();
+ if (!Tok.is(tok::annot_typename))
return TPResult::False();
// If that succeeded, fallthrough into the generic simple-type-id case.
OpenPOWER on IntegriCloud