aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-31 05:01:50 +0000
committerChris Lattner <sabre@nondot.org>2007-08-31 05:01:50 +0000
commitd56d6b678f1cd6d34bc957a42453d1e237289048 (patch)
tree4d709023d381d982f0a3813ab40c4a572986051c
parentdbd583cfc57d7783b4ac5e5a862b3856fcaad53b (diff)
don't turn semantic errors into parse errors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41638 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Parse/ParseExpr.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/Parse/ParseExpr.cpp b/Parse/ParseExpr.cpp
index 3e70db4c48..51ad217e31 100644
--- a/Parse/ParseExpr.cpp
+++ b/Parse/ParseExpr.cpp
@@ -374,15 +374,19 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
}
assert(NextTokPrec <= ThisPrec && "Recursion didn't work!");
- // Combine the LHS and RHS into the LHS (e.g. build AST).
- if (TernaryMiddle.isInvalid)
- LHS = Actions.ParseBinOp(OpToken.getLocation(), OpToken.getKind(),
- LHS.Val, RHS.Val);
- else
- LHS = Actions.ParseConditionalOp(OpToken.getLocation(), ColonLoc,
- LHS.Val, TernaryMiddle.Val, RHS.Val);
- if (LHS.isInvalid)
- return LHS;
+ if (!LHS.isInvalid) {
+ // Combine the LHS and RHS into the LHS (e.g. build AST).
+ if (TernaryMiddle.isInvalid)
+ LHS = Actions.ParseBinOp(OpToken.getLocation(), OpToken.getKind(),
+ LHS.Val, RHS.Val);
+ else
+ LHS = Actions.ParseConditionalOp(OpToken.getLocation(), ColonLoc,
+ LHS.Val, TernaryMiddle.Val, RHS.Val);
+ } else {
+ // We had a semantic error on the LHS. Just free the RHS and continue.
+ Actions.DeleteExpr(TernaryMiddle.Val);
+ Actions.DeleteExpr(RHS.Val);
+ }
}
}