From 42ece6424fcfe74bda29bb22a8bfcc8b9769ebcd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 12 Dec 2008 06:00:12 +0000 Subject: [PATCH] minor refactoring of ParseParenExpression git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60928 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseExpr.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index ac3a46a001..b18d505364 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -1062,34 +1062,37 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, if (!Result.isInvalid()) return Owned(Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc, Result.release())); - } else if (ExprType == CastExpr) { + return move(Result); + } + + if (ExprType == CastExpr) { // Note that this doesn't parse the subsequence cast-expression, it just // returns the parsed type to the callee. ExprType = CastExpr; CastTy = Ty; return OwningExprResult(Actions); - } else { - Diag(Tok, diag::err_expected_lbrace_in_compound_literal); - return ExprError(); } - return move(Result); + + Diag(Tok, diag::err_expected_lbrace_in_compound_literal); + return ExprError(); } else { Result = ParseExpression(); ExprType = SimpleExpr; if (!Result.isInvalid() && Tok.is(tok::r_paren)) - Result = Actions.ActOnParenExpr( - OpenLoc, Tok.getLocation(), Result.release()); + Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), + Result.release()); } // Match the ')'. - if (Result.isInvalid()) + if (Result.isInvalid()) { SkipUntil(tok::r_paren); - else { - if (Tok.is(tok::r_paren)) - RParenLoc = ConsumeParen(); - else - MatchRHSPunctuation(tok::r_paren, OpenLoc); + return ExprError(); } + + if (Tok.is(tok::r_paren)) + RParenLoc = ConsumeParen(); + else + MatchRHSPunctuation(tok::r_paren, OpenLoc); return move(Result); } -- 2.40.0