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:
David Majnemer 2015-01-09 18:09:39 +00:00
parent 2bcfc6f95e
commit d527199c37
2 changed files with 12 additions and 3 deletions

View File

@ -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;

View File

@ -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();
}