https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/177452
>From 3a32ad13def1097459b5c854960438d383735ea1 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Thu, 22 Jan 2026 15:13:29 -0500 Subject: [PATCH 1/3] [Clang][Sema] Only call PerformDependentDiagnostics for dependent contexts --- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 ++- clang/test/SemaTemplate/GH176155.cpp | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaTemplate/GH176155.cpp diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 972981d7c11fb..cc24e03e77c07 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -5969,7 +5969,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, checkReferenceToTULocalFromOtherTU(Function, PointOfInstantiation); - PerformDependentDiagnostics(PatternDecl, TemplateArgs); + if (PatternDecl->isDependentContext()) + PerformDependentDiagnostics(PatternDecl, TemplateArgs); if (auto *Listener = getASTMutationListener()) Listener->FunctionDefinitionInstantiated(Function); diff --git a/clang/test/SemaTemplate/GH176155.cpp b/clang/test/SemaTemplate/GH176155.cpp new file mode 100644 index 0000000000000..566cb5f66a04a --- /dev/null +++ b/clang/test/SemaTemplate/GH176155.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +template <int> struct bad { + template <class T, auto = + [] { // #lambda + for (int i = 0; i < 100; ++i) { // #i + // expected-error@-1 {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} + // expected-note@#i {{'i' declared here}} + // expected-note@#lambda {{lambda expression begins here}} + // expected-error@-4 {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} + // expected-note@#i {{'i' declared here}} + // expected-note@#lambda {{lambda expression begins here}} + struct LoopHelper { + static constexpr void process() {} + }; + } + }> + static void f(T) {} // expected-note {{in instantiation of default argument for 'f<int>' required here}} +}; + +int main() { bad<0>::f(0); } // expected-note {{while substituting deduced template arguments into function template 'f'}} >From dbfb17e10ea91ff0415d4b5c725294801b58d960 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Thu, 22 Jan 2026 15:37:12 -0500 Subject: [PATCH 2/3] [FOLD] fix test --- clang/test/SemaTemplate/GH176155.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/test/SemaTemplate/GH176155.cpp b/clang/test/SemaTemplate/GH176155.cpp index 566cb5f66a04a..12a9de2ae2d46 100644 --- a/clang/test/SemaTemplate/GH176155.cpp +++ b/clang/test/SemaTemplate/GH176155.cpp @@ -3,6 +3,11 @@ template <int> struct bad { template <class T, auto = [] { // #lambda + // expected-note@#lambda {{while substituting into a lambda expression here}} + // expected-note@#lambda 2{{capture 'i' by value}} + // expected-note@#lambda 2{{capture 'i' by reference}} + // expected-note@#lambda 2{{default capture by value}} + // expected-note@#lambda 2{{default capture by reference}} for (int i = 0; i < 100; ++i) { // #i // expected-error@-1 {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} // expected-note@#i {{'i' declared here}} >From 44a354fff9f57a948df0a7715278365e7e9e2297 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <[email protected]> Date: Thu, 12 Mar 2026 11:24:27 -0400 Subject: [PATCH 3/3] 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 3617786f09595..0731c4bf8b418 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -322,6 +322,7 @@ Bug Fixes in This Version - Fixed a crash when parsing ``#pragma clang attribute`` arguments for attributes that forbid arguments. (#GH182122) - 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. Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
