llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: TPPPP (TPPPP72) <details> <summary>Changes</summary> Added extra checks to ParseDeclarationSpecifiers to prevent multiple type specifiers from being assigned to the same DeclSpec. --- Full diff: https://github.com/llvm/llvm-project/pull/187921.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Parse/ParseDecl.cpp (+12) - (added) clang/test/SemaTemplate/gh187664.cpp (+14) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b92f1ab34aa51..1744357fde4bd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -382,6 +382,7 @@ Bug Fixes to AST Handling - Fixed a bug where explicit nullability property attributes were not stored in AST nodes in Objective-C. (#GH179703) - Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid declarations or non-function entities. (#GH182737) - Fixed a assertion when __block is used on global variables in C mode. (#GH183974) +- Fixed a crash when a type-name is incorrectly combined with a class specifier within a template default argument. (#GH187664) Miscellaneous Bug Fixes ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 72935f427b7f8..6cab4bfe8123d 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4456,6 +4456,18 @@ void Parser::ParseDeclarationSpecifiers( case tok::kw___interface: case tok::kw_union: { tok::TokenKind Kind = Tok.getKind(); + + // If already has a TST, skip it. + if (DS.getTypeSpecType() != DeclSpec::TST_unspecified) { + Diag(Tok, diag::err_invalid_decl_spec_combination) + << DeclSpec::getSpecifierName(DS.getTypeSpecType(), + Actions.getPrintingPolicy()); + + ConsumeToken(); + DS.SetTypeSpecError(); + continue; + } + ConsumeToken(); // These are attributes following class specifiers. diff --git a/clang/test/SemaTemplate/gh187664.cpp b/clang/test/SemaTemplate/gh187664.cpp new file mode 100644 index 0000000000000..441671c543f7e --- /dev/null +++ b/clang/test/SemaTemplate/gh187664.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s + +class A { +public: + class B {}; +}; + +using X = A::B; + +class C { + template <typename T = X class A::B> void f(); + // expected-error@-1 {{cannot combine with previous 'type-name' declaration specifier}} + // expected-error@-2 {{expected ',' or '>' in template-parameter-list}} +}; `````````` </details> https://github.com/llvm/llvm-project/pull/187921 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
