forked from OSchip/llvm-project
Parse: Don't crash when an annotation token shows up in a C++11 attr
It's not safe to blindly call getIdentifierInfo without checking the token is not an annotation token. llvm-svn: 225533
This commit is contained in:
parent
2bcfc6f95e
commit
d527199c37
|
@ -3386,9 +3386,11 @@ IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc) {
|
|||
switch (Tok.getKind()) {
|
||||
default:
|
||||
// Identifiers and keywords have identifier info attached.
|
||||
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
|
||||
Loc = ConsumeToken();
|
||||
return II;
|
||||
if (!Tok.isAnnotation()) {
|
||||
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
|
||||
Loc = ConsumeToken();
|
||||
return II;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -334,3 +334,10 @@ namespace {
|
|||
[[deprecated()]] void foo(); // expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
|
||||
[[gnu::deprecated()]] void quux();
|
||||
}
|
||||
|
||||
namespace {
|
||||
[[ // expected-error {{expected ']'}}
|
||||
#pragma pack(pop)
|
||||
deprecated
|
||||
]] void bad();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue