aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-12 06:00:12 +0000
committerChris Lattner <sabre@nondot.org>2008-12-12 06:00:12 +0000
commit42ece6424fcfe74bda29bb22a8bfcc8b9769ebcd (patch)
tree33adeced0891065c8cc52a0bcb32963d2d9d0c0a /lib/Parse/ParseExpr.cpp
parent4209a3909d827efb7648a9355f2976ca656da704 (diff)
minor refactoring of ParseParenExpression
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp29
1 files 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);
}