aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-02 00:37:27 +0000
committerChris Lattner <sabre@nondot.org>2010-02-02 00:37:27 +0000
commit3e156ad9adc7332e626eedbc86aa4e3b03f17ca5 (patch)
tree6bc14dc8d4644cbaaf8dae91ae65859cf9e6b8c1 /lib/Parse/ParseDecl.cpp
parentedf21bce6e64aade65d960f76dfd09a6dc1929b1 (diff)
improve diagnostics on missing ; in a struct. Before:
t.c:4:3: error: expected ';' at end of declaration list int y; ^ t.c:4:8: warning: extra ';' inside a struct or union int y; ^ t.c:6:1: warning: expected ';' at end of declaration list }; ^ After: t.c:3:8: error: expected ';' at end of declaration list int x // expected-error {{expected ';' at end of declaration list}} ^ ; t.c:5:8: warning: expected ';' at end of declaration list int z ^ ; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 8cf7a63397..5a5f5092db 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -1750,14 +1750,14 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
ConsumeToken();
if (!Tok.isObjCAtKeyword(tok::objc_defs)) {
Diag(Tok, diag::err_unexpected_at);
- SkipUntil(tok::semi, true, true);
+ SkipUntil(tok::semi, true);
continue;
}
ConsumeToken();
ExpectAndConsume(tok::l_paren, diag::err_expected_lparen);
if (!Tok.is(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
- SkipUntil(tok::semi, true, true);
+ SkipUntil(tok::semi, true);
continue;
}
llvm::SmallVector<DeclPtrTy, 16> Fields;
@@ -1771,12 +1771,14 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
if (Tok.is(tok::semi)) {
ConsumeToken();
} else if (Tok.is(tok::r_brace)) {
- Diag(Tok, diag::ext_expected_semi_decl_list);
+ ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
break;
} else {
- Diag(Tok, diag::err_expected_semi_decl_list);
- // Skip to end of block or statement
+ ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
+ // Skip to end of block or statement to avoid ext-warning on extra ';'.
SkipUntil(tok::r_brace, true, true);
+ // If we stopped at a ';', eat it.
+ if (Tok.is(tok::semi)) ConsumeToken();
}
}