[cfe-commits] r61160 - in /cfe/trunk: lib/Parse/ParseStmt.cpp test/Parser/recovery.c
Eli Friedman
eli.friedman at gmail.com
Wed Dec 17 14:19:58 PST 2008
Author: efriedma
Date: Wed Dec 17 16:19:57 2008
New Revision: 61160
URL: http://llvm.org/viewvc/llvm-project?rev=61160&view=rev
Log:
Do proper recovery from an invalid switch condiition. Fixes PR3229.
Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/Parser/recovery.c
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=61160&r1=61159&r2=61160&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Wed Dec 17 16:19:57 2008
@@ -611,9 +611,10 @@
OwningExprResult Cond(Actions);
if (ParseParenExprOrCondition(Cond))
return StmtError();
-
- OwningStmtResult Switch(Actions,
- Actions.ActOnStartOfSwitchStmt(Cond.release()));
+
+ OwningStmtResult Switch(Actions);
+ if (!Cond.isInvalid())
+ Switch = Actions.ActOnStartOfSwitchStmt(Cond.release());
// C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
Modified: cfe/trunk/test/Parser/recovery.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.c?rev=61160&r1=61159&r2=61160&view=diff
==============================================================================
--- cfe/trunk/test/Parser/recovery.c (original)
+++ cfe/trunk/test/Parser/recovery.c Wed Dec 17 16:19:57 2008
@@ -65,3 +65,6 @@
[10] // expected-error {{expected expression}}
}
+struct forward;
+void x(struct forward* x) {switch(x->a) {}}
+
More information about the cfe-commits
mailing list