From 1f476a1783d95d9b53b10f763789e8afeded42f3 Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 26 Feb 2010 08:45:28 +0000 Subject: 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 --- clang/lib/Parse/ParseTentative.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'clang/lib/Parse/ParseTentative.cpp') 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. -- cgit v1.2.3