mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 16:41:43 +00:00
Fix PR3031 by silencing follow-on errors in invalid declarations.
llvm-svn: 59027
This commit is contained in:
parent
2126a6d3c4
commit
8c5dd730ce
@ -1494,6 +1494,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
|
|||||||
else
|
else
|
||||||
Diag(Tok, diag::err_expected_ident_lparen); // Expected identifier or '('.
|
Diag(Tok, diag::err_expected_ident_lparen); // Expected identifier or '('.
|
||||||
D.SetIdentifier(0, Tok.getLocation());
|
D.SetIdentifier(0, Tok.getLocation());
|
||||||
|
D.setInvalidType(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(D.isPastIdentifier() &&
|
assert(D.isPastIdentifier() &&
|
||||||
|
@ -753,9 +753,10 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
|
|||||||
// All of these full declarators require an identifier. If it doesn't have
|
// All of these full declarators require an identifier. If it doesn't have
|
||||||
// one, the ParsedFreeStandingDeclSpec action should be used.
|
// one, the ParsedFreeStandingDeclSpec action should be used.
|
||||||
if (II == 0) {
|
if (II == 0) {
|
||||||
Diag(D.getDeclSpec().getSourceRange().getBegin(),
|
if (!D.getInvalidType()) // Reject this if we think it is valid.
|
||||||
diag::err_declarator_need_ident,
|
Diag(D.getDeclSpec().getSourceRange().getBegin(),
|
||||||
D.getDeclSpec().getSourceRange(), D.getSourceRange());
|
diag::err_declarator_need_ident,
|
||||||
|
D.getDeclSpec().getSourceRange(), D.getSourceRange());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,3 +32,7 @@ int test3(x,
|
|||||||
|
|
||||||
int test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
|
int test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
|
||||||
|
|
||||||
|
|
||||||
|
// PR3031
|
||||||
|
int (test5), ; // expected-error {{expected identifier or '('}}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ int *h = &x;
|
|||||||
int test() {
|
int test() {
|
||||||
int a[10];
|
int a[10];
|
||||||
int b[10] = a; // expected-error {{initialization with "{...}" expected}}
|
int b[10] = a; // expected-error {{initialization with "{...}" expected}}
|
||||||
int +; // expected-error {{expected identifier or '('}} expected-error {{declarator requires an identifier}} expected-error {{parse error}}
|
int +; // expected-error {{expected identifier or '('}} expected-error {{parse error}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
// RUN: clang %s -fsyntax-only -verify
|
// RUN: clang %s -fsyntax-only -verify
|
||||||
|
|
||||||
void test() {
|
void test() {
|
||||||
char = 4; // expected-error {{expected identifier}} expected-error{{declarator requires an identifier}}
|
char = 4; // expected-error {{expected identifier}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user