зеркало из https://github.com/microsoft/clang-1.git
improve diagnostics for C++ struct ; issues. Before:
t.cc:4:3: error: expected ';' at end of declaration list int y; ^ t.cc:6:1: error: expected ';' at end of declaration list }; ^ After: t.cc:3:8: error: expected ';' at end of declaration list int x ^ ; t.cc:5:8: error: expected ';' at end of declaration list int z ^ ; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
3e156ad9ad
Коммит
ae50d501f4
|
@ -1189,8 +1189,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
|
|||
if (Tok.is(tok::kw_namespace)) {
|
||||
Diag(UsingLoc, diag::err_using_namespace_in_class);
|
||||
SkipUntil(tok::semi, true, true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SourceLocation DeclEnd;
|
||||
// Otherwise, it must be using-declaration.
|
||||
ParseUsingDeclaration(Declarator::MemberContext, UsingLoc, DeclEnd, AS);
|
||||
|
@ -1371,19 +1370,16 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
|
|||
ParseDeclarator(DeclaratorInfo);
|
||||
}
|
||||
|
||||
if (Tok.is(tok::semi)) {
|
||||
ConsumeToken();
|
||||
Actions.FinalizeDeclaratorGroup(CurScope, DS, DeclsInGroup.data(),
|
||||
DeclsInGroup.size());
|
||||
if (ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
|
||||
// Skip to end of block or statement.
|
||||
SkipUntil(tok::r_brace, true, true);
|
||||
// If we stopped at a ';', eat it.
|
||||
if (Tok.is(tok::semi)) ConsumeToken();
|
||||
return;
|
||||
}
|
||||
|
||||
Diag(Tok, diag::err_expected_semi_decl_list);
|
||||
// Skip to end of block or statement
|
||||
SkipUntil(tok::r_brace, true, true);
|
||||
if (Tok.is(tok::semi))
|
||||
ConsumeToken();
|
||||
return;
|
||||
Actions.FinalizeDeclaratorGroup(CurScope, DS, DeclsInGroup.data(),
|
||||
DeclsInGroup.size());
|
||||
}
|
||||
|
||||
/// ParseCXXMemberSpecification - Parse the class definition.
|
||||
|
|
|
@ -52,3 +52,9 @@ void test(struct Type *P) {
|
|||
(y:b) // expected-error {{unexpected ':' in nested name specifier}}
|
||||
4) : 5;
|
||||
}
|
||||
|
||||
struct test4 {
|
||||
int x // expected-error {{expected ';' at end of declaration list}}
|
||||
int y;
|
||||
int z // expected-error {{expected ';' at end of declaration list}}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче