minor refactoring of ParseParenExpression
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60928 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index ac3a46a..b18d505 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1062,34 +1062,37 @@
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);
}