https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/186200
>From ba8bac94d5615d60149bc18d2921ebd250ace669 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Mon, 26 Jan 2026 15:28:29 -0500 Subject: [PATCH 1/3] [Clang] Fix crash in CheckNonTypeTemplateParameterType with invalid type SubstAutoTypeSourceInfoDependent can return null when transforming an invalid type containing decltype(auto). Handle this case by returning QualType() to signal failure. Fixes #177545 --- clang/lib/Sema/SemaTemplate.cpp | 5 ++++- clang/test/SemaTemplate/deduction-crash.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 9b0bec20618a0..9194ee5e2bee9 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1342,7 +1342,10 @@ QualType Sema::CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, // - an identifier associated by name lookup with a non-type // template-parameter declared with a type that contains a // placeholder type (7.1.7.4), - TSI = SubstAutoTypeSourceInfoDependent(TSI); + TypeSourceInfo *NewTSI = SubstAutoTypeSourceInfoDependent(TSI); + if (!NewTSI) + return QualType(); + TSI = NewTSI; } return CheckNonTypeTemplateParameterType(TSI->getType(), Loc); diff --git a/clang/test/SemaTemplate/deduction-crash.cpp b/clang/test/SemaTemplate/deduction-crash.cpp index 99ca0b365ff6f..7c3e92af068e9 100644 --- a/clang/test/SemaTemplate/deduction-crash.cpp +++ b/clang/test/SemaTemplate/deduction-crash.cpp @@ -172,3 +172,8 @@ namespace PR51872_part1 { // expected-error@-1 {{no viable constructor or deduction guide for deduction of template arguments of 'T1'}} // expected-note@-7 {{candidate template ignored: could not match 'PR51872_part1::T1<value-parameter-0-0>' against 'int'}} } + +namespace GH177545 { + template<decltype(auto)()() volatile throw() -> char> // expected-error {{'decltype(auto)' can only be used as a return type in a function declaration}} + struct T2; // expected-error@-1 {{function cannot return function type 'auto () volatile throw() -> decltype(auto)'}} +} >From 4ef0c2f5246380d9d6978dff0b85862fc05a66c3 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Thu, 12 Mar 2026 13:52:27 -0400 Subject: [PATCH 2/3] [FOLD] add release note --- clang/docs/ReleaseNotes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 031d7405e7f58..e4f09596a7937 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -327,6 +327,7 @@ Bug Fixes in This Version - Fixed a bug with multiple-include optimization (MIOpt) state not being preserved in some cases during lexing, which could suppress header-guard mismatch diagnostics and interfere with include-guard optimization. (#GH180155) - Fixed a crash when normalizing constraints involving concept template parameters whose index coincided with non-concept template parameters in the same parameter mapping. - Fixed a crash caused by accessing dependent diagnostics of a non-dependent context. +- Fixed a crash when substituting into a non-type template parameter that has a type containing an undeduced placeholder type. Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >From 352d165652a83a9a96edccbdbc4bfc3183b3a1fc Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Fri, 13 Mar 2026 08:40:52 -0400 Subject: [PATCH 3/3] [FOLD] fix test --- clang/test/SemaTemplate/deduction-crash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/SemaTemplate/deduction-crash.cpp b/clang/test/SemaTemplate/deduction-crash.cpp index 7c3e92af068e9..e7018fd0d8338 100644 --- a/clang/test/SemaTemplate/deduction-crash.cpp +++ b/clang/test/SemaTemplate/deduction-crash.cpp @@ -175,5 +175,5 @@ namespace PR51872_part1 { namespace GH177545 { template<decltype(auto)()() volatile throw() -> char> // expected-error {{'decltype(auto)' can only be used as a return type in a function declaration}} - struct T2; // expected-error@-1 {{function cannot return function type 'auto () volatile throw() -> decltype(auto)'}} + struct T2; // expected-error@* {{function cannot return function type 'auto () volatile throw() -> decltype(auto)'}} } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
