forked from OSchip/llvm-project
[clang] Fix crash on broken parameter declarators
Differential Revision: https://reviews.llvm.org/D114609
This commit is contained in:
parent
40e7d4cd3b
commit
d026f2f7c6
|
@ -6978,13 +6978,13 @@ void Parser::ParseParameterDeclarationClause(
|
|||
//
|
||||
// We care about case 1) where the declarator type should be known, and
|
||||
// the identifier should be null.
|
||||
if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName()) {
|
||||
if (Tok.getIdentifierInfo() &&
|
||||
Tok.getIdentifierInfo()->isKeyword(getLangOpts())) {
|
||||
Diag(Tok, diag::err_keyword_as_parameter) << PP.getSpelling(Tok);
|
||||
// Consume the keyword.
|
||||
ConsumeToken();
|
||||
}
|
||||
if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName() &&
|
||||
Tok.isNot(tok::raw_identifier) && !Tok.isAnnotation() &&
|
||||
Tok.getIdentifierInfo() &&
|
||||
Tok.getIdentifierInfo()->isKeyword(getLangOpts())) {
|
||||
Diag(Tok, diag::err_keyword_as_parameter) << PP.getSpelling(Tok);
|
||||
// Consume the keyword.
|
||||
ConsumeToken();
|
||||
}
|
||||
// Inform the actions module about the parameter declarator, so it gets
|
||||
// added to the current scope.
|
||||
|
|
|
@ -25,3 +25,7 @@ void test() {
|
|||
int case; // expected-error {{expected member name or ';'}}
|
||||
};
|
||||
}
|
||||
struct Foo {
|
||||
void bar(*decltype(1) aux); // expected-error {{C++ requires a type specifier for all declarations}}. \
|
||||
// expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue