https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/89227
>From 04c5dfa09f78fa52b31378295a8d27a20278498a Mon Sep 17 00:00:00 2001 From: Haojian Wu <hokein...@gmail.com> Date: Thu, 18 Apr 2024 14:50:51 +0200 Subject: [PATCH 1/2] [clang] Fix a "!CodeSynthesisContexts.empty()" assertion failure when constructing the aggregate deduction guides. We were missing to push an record to the instantiation stack in `DeclareAggregateDeductionGuideForTypeAlias`. This patch fixes that. --- clang/lib/Sema/SemaTemplate.cpp | 5 +++++ clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 95171359f0ab17..8b039c26f2cef5 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3043,6 +3043,11 @@ FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias( return nullptr; LocalInstantiationScope Scope(SemaRef); + Sema::InstantiatingTemplate BuildingDeductionGuides( + SemaRef, AliasTemplate->getLocation(), RHSDeductionGuide, + Sema::InstantiatingTemplate::BuildingDeductionGuidesTag{}); + if (BuildingDeductionGuides.isInvalid()) + return nullptr; // Build a new template parameter list for the synthesized aggregate deduction // guide by transforming the one from RHSDeductionGuide. diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp index b71cd46f884d63..6f04264a655ad5 100644 --- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp +++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp @@ -279,3 +279,13 @@ Bar t = Foo<K<Container>>(); Bar s = 1; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of}} } // namespace test20 + +namespace test21 { +template <typename T, unsigned N> +struct Array { const T member[N]; }; +template <unsigned N> +using String = Array<char, N>; + +// Verify no crash on constructing the aggregate deduction guides. +String s("hello"); +} // namespace test21 >From e3bb6181bb8a79f674e816cd54fbbcc11c1e0803 Mon Sep 17 00:00:00 2001 From: Haojian Wu <hokein...@gmail.com> Date: Thu, 18 Apr 2024 15:07:14 +0200 Subject: [PATCH 2/2] Fix format --- clang/lib/Sema/SemaTemplate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 8b039c26f2cef5..57752ce02049aa 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3044,8 +3044,8 @@ FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias( LocalInstantiationScope Scope(SemaRef); Sema::InstantiatingTemplate BuildingDeductionGuides( - SemaRef, AliasTemplate->getLocation(), RHSDeductionGuide, - Sema::InstantiatingTemplate::BuildingDeductionGuidesTag{}); + SemaRef, AliasTemplate->getLocation(), RHSDeductionGuide, + Sema::InstantiatingTemplate::BuildingDeductionGuidesTag{}); if (BuildingDeductionGuides.isInvalid()) return nullptr; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits