summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-04-28 16:24:20 +0000
committerChris Lattner <sabre@nondot.org>2012-04-28 16:24:20 +0000
commit70d4498899248bb1fff4ba9f9468cc08907d347d (patch)
tree12326d2493b0fff7784b6a1336d18610b2372d2b /clang/lib/Parse/ParseStmt.cpp
parentf819ae609288e8904c1e772727c0b653805cba20 (diff)
downloadbcm5719-llvm-70d4498899248bb1fff4ba9f9468cc08907d347d.tar.gz
bcm5719-llvm-70d4498899248bb1fff4ba9f9468cc08907d347d.zip
improve error recovery for extra ')'s after a if/switch/while condition. Before:
t.c:3:9: error: expected expression if (x)) { ^ .. which isn't even true - a statement or expression is fine. After: t.c:3:9: error: extraneous ')' after condition, expected a statement if (x)) { ^ This is the second part of PR12595 llvm-svn: 155762
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 8dd0a2a5dc8..9796ea69bac 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -895,6 +895,16 @@ bool Parser::ParseParenExprOrCondition(ExprResult &ExprResult,
// Otherwise the condition is valid or the rparen is present.
T.consumeClose();
+
+ // Check for extraneous ')'s to catch things like "if (foo())) {". We know
+ // that all callers are looking for a statement after the condition, so ")"
+ // isn't valid.
+ while (Tok.is(tok::r_paren)) {
+ Diag(Tok, diag::err_extraneous_rparen_in_condition)
+ << FixItHint::CreateRemoval(Tok.getLocation());
+ ConsumeParen();
+ }
+
return false;
}
OpenPOWER on IntegriCloud