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()) {
|
switch (Tok.getKind()) {
|
||||||
default:
|
default:
|
||||||
// Identifiers and keywords have identifier info attached.
|
// Identifiers and keywords have identifier info attached.
|
||||||
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
|
if (!Tok.isAnnotation()) {
|
||||||
Loc = ConsumeToken();
|
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
|
||||||
return II;
|
Loc = ConsumeToken();
|
||||||
|
return II;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -334,3 +334,10 @@ namespace {
|
||||||
[[deprecated()]] void foo(); // expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
|
[[deprecated()]] void foo(); // expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
|
||||||
[[gnu::deprecated()]] void quux();
|
[[gnu::deprecated()]] void quux();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
[[ // expected-error {{expected ']'}}
|
||||||
|
#pragma pack(pop)
|
||||||
|
deprecated
|
||||||
|
]] void bad();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue