kadircet created this revision. kadircet added reviewers: sammccall, hokein. kadircet requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114609 Files: clang/lib/Parse/ParseDecl.cpp clang/test/Parser/cxx-decltype-parameter.cpp Index: clang/test/Parser/cxx-decltype-parameter.cpp =================================================================== --- /dev/null +++ clang/test/Parser/cxx-decltype-parameter.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct Bar {}; +struct Foo { + Bar bar(*decltype(Bar{}) aux); // expected-error {{C++ requires a type specifier for all declarations}}. \ + // expected-error {{expected ')'}} expected-note {{to match this '('}} +}; Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ 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.
Index: clang/test/Parser/cxx-decltype-parameter.cpp =================================================================== --- /dev/null +++ clang/test/Parser/cxx-decltype-parameter.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct Bar {}; +struct Foo { + Bar bar(*decltype(Bar{}) aux); // expected-error {{C++ requires a type specifier for all declarations}}. \ + // expected-error {{expected ')'}} expected-note {{to match this '('}} +}; Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits