llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Haojian Wu (hokein) <details> <summary>Changes</summary> the template arguments of the RHS. Fixes https://github.com/llvm/llvm-project/issues/85385. The Finder was missing for this case, for the crash test, the template parameter TTP was incorrectly considered as not referenced/appeared in the template arguments of the right hand side of the alias template decl, thus the synthesized deduction decl doesn't contain this TTP in the template parameter list, but we have references in the declaration, thus it caused crashes. --- Full diff: https://github.com/llvm/llvm-project/pull/85405.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplate.cpp (+6) - (modified) clang/test/SemaCXX/cxx20-ctad-type-alias.cpp (+16) ``````````diff diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 51e8db2dfbaac8..27714066d2748b 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2696,6 +2696,12 @@ SmallVector<unsigned> TemplateParamsReferencedInTemplateArgumentList( return true; } + bool TraverseTemplateName(TemplateName Template) { + if (auto *TD = Template.getAsTemplateDecl()) + MarkAppeared(TD); + return RecursiveASTVisitor::TraverseTemplateName(Template); + } + void MarkAppeared(NamedDecl *ND) { if (TemplateParams.contains(ND)) ReferencedTemplateParams.insert(ND); diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp index 3ce26c8fcd984e..7ada48b7e58f01 100644 --- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp +++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp @@ -247,3 +247,19 @@ using Bar = Foo<U>; // expected-note {{could not match 'Foo<type-parameter-0-0>' Bar s = {1}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments}} } // namespace test18 + +// GH85385 +namespace test19 { +template <template <typename> typename T> +struct K {}; + +template <typename U> +class Foo {}; + +// Verify that template template type parameter TTP is referenced/used in the +// template arguments of the RHS. +template <template<typename> typename TTP> +using Bar = Foo<K<TTP>>; // expected-note {{candidate template ignored: could not match 'Foo<K<>>' against 'int'}} + +Bar s = 1; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of}} +} `````````` </details> https://github.com/llvm/llvm-project/pull/85405 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits