diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -6978,13 +6978,13 @@ // // 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. diff --git a/clang/test/Parser/cxx-keyword-identifiers.cpp b/clang/test/Parser/cxx-keyword-identifiers.cpp --- a/clang/test/Parser/cxx-keyword-identifiers.cpp +++ b/clang/test/Parser/cxx-keyword-identifiers.cpp @@ -25,3 +25,7 @@ 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 '('}} +};