diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-02-18 17:45:20 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-02-18 17:45:20 +0000 |
| commit | 220cac5e898d1c89f1813a9198e2c4b4a0f25012 (patch) | |
| tree | c49b52296042d55afad66e6075396e795bbfe8b8 /clang/lib/Parse/ParseExprCXX.cpp | |
| parent | ab89bc8ca1d93f7052daff3b7ca3b361fc83a47b (diff) | |
| download | bcm5719-llvm-220cac5e898d1c89f1813a9198e2c4b4a0f25012.tar.gz bcm5719-llvm-220cac5e898d1c89f1813a9198e2c4b4a0f25012.zip | |
Update Parser::ParseTypeName to return a TypeResult, which also tells
us whether there was an error in trying to parse a type-name (type-id
in C++). This allows propagation of errors further in the compiler,
suppressing more bogus error messages.
llvm-svn: 64922
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index e8ef8ea61ee..fb60bde4f1e 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -211,7 +211,7 @@ Parser::OwningExprResult Parser::ParseCXXCasts() { if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName)) return ExprError(); - TypeTy *CastTy = ParseTypeName(); + TypeResult CastTy = ParseTypeName(); SourceLocation RAngleBracketLoc = Tok.getLocation(); if (ExpectAndConsume(tok::greater, diag::err_expected_greater)) @@ -224,9 +224,10 @@ Parser::OwningExprResult Parser::ParseCXXCasts() { OwningExprResult Result(ParseSimpleParenExpression(RParenLoc)); - if (!Result.isInvalid()) + if (!Result.isInvalid() && !CastTy.isInvalid()) Result = Actions.ActOnCXXNamedCast(OpLoc, Kind, - LAngleBracketLoc, CastTy, RAngleBracketLoc, + LAngleBracketLoc, CastTy.get(), + RAngleBracketLoc, LParenLoc, Result.release(), RParenLoc); return move(Result); @@ -253,16 +254,16 @@ Parser::OwningExprResult Parser::ParseCXXTypeid() { OwningExprResult Result(Actions); if (isTypeIdInParens()) { - TypeTy *Ty = ParseTypeName(); + TypeResult Ty = ParseTypeName(); // Match the ')'. MatchRHSPunctuation(tok::r_paren, LParenLoc); - if (!Ty) + if (Ty.isInvalid()) return ExprError(); Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/true, - Ty, RParenLoc); + Ty.get(), RParenLoc); } else { Result = ParseExpression(); @@ -919,9 +920,12 @@ Parser::OwningExprResult Parser::ParseUnaryTypeTrait() // FIXME: Error reporting absolutely sucks! If the this fails to parse a type // there will be cryptic errors about mismatched parentheses and missing // specifiers. - TypeTy *Ty = ParseTypeName(); + TypeResult Ty = ParseTypeName(); SourceLocation RParen = MatchRHSPunctuation(tok::r_paren, LParen); - return Actions.ActOnUnaryTypeTrait(UTT, Loc, LParen, Ty, RParen); + if (Ty.isInvalid()) + return ExprError(); + + return Actions.ActOnUnaryTypeTrait(UTT, Loc, LParen, Ty.get(), RParen); } |

