[cfe-commits] r99972 - in /cfe/trunk: lib/Parse/ParseStmt.cpp test/Index/recover-bad-code-rdar_7487294.c test/Parser/statements.c
Argiris Kirtzidis
akyrtzi at gmail.com
Tue Mar 30 17:37:59 PDT 2010
Author: akirtzidis
Date: Tue Mar 30 19:37:59 2010
New Revision: 99972
URL: http://llvm.org/viewvc/llvm-project?rev=99972&view=rev
Log:
Don't skip past the '}' if an expression has error and is not followed by ';'.
Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c
cfe/trunk/test/Parser/statements.c
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=99972&r1=99971&r2=99972&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Mar 30 19:37:59 2010
@@ -125,10 +125,12 @@
// expression[opt] ';'
OwningExprResult Expr(ParseExpression());
if (Expr.isInvalid()) {
- // If the expression is invalid, skip ahead to the next semicolon. Not
- // doing this opens us up to the possibility of infinite loops if
+ // If the expression is invalid, skip ahead to the next semicolon or '}'.
+ // Not doing this opens us up to the possibility of infinite loops if
// ParseExpression does not consume any tokens.
- SkipUntil(tok::semi);
+ SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true);
+ if (Tok.is(tok::semi))
+ ConsumeToken();
return StmtError();
}
// Otherwise, eat the semicolon.
Modified: cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c?rev=99972&r1=99971&r2=99972&view=diff
==============================================================================
--- cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c (original)
+++ cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c Tue Mar 30 19:37:59 2010
@@ -11,4 +11,3 @@
// CHECK: 9:3: error: use of undeclared identifier 'help'
// CHECK: help
-// CHECK: 14:102: error: expected '}'
Modified: cfe/trunk/test/Parser/statements.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/statements.c?rev=99972&r1=99971&r2=99972&view=diff
==============================================================================
--- cfe/trunk/test/Parser/statements.c (original)
+++ cfe/trunk/test/Parser/statements.c Tue Mar 30 19:37:59 2010
@@ -57,3 +57,8 @@
int test7() {
return 4 // expected-error {{expected ';' after return statement}}
}
+
+void test8() {
+ // Should not skip '}' and produce a "expected '}'" error.
+ undecl // expected-error {{use of undeclared identifier 'undecl'}}
+}
More information about the cfe-commits
mailing list