[clang] b59567b - [clang] always use resolved arguments for default argument deduction (#94756)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 7 09:22:31 PDT 2024
Author: Matheus Izvekov
Date: 2024-06-07T13:22:26-03:00
New Revision: b59567b99a44e9fe423e8712123f864b0c83eebc
URL: https://github.com/llvm/llvm-project/commit/b59567b99a44e9fe423e8712123f864b0c83eebc
DIFF: https://github.com/llvm/llvm-project/commit/b59567b99a44e9fe423e8712123f864b0c83eebc.diff
LOG: [clang] always use resolved arguments for default argument deduction (#94756)
Added:
Modified:
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/cwg2398.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1011db2d2830d..befeb38e1fe5b 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -712,13 +712,6 @@ DeduceTemplateSpecArguments(Sema &S, TemplateParameterList *TemplateParams,
if (const auto *TD = TNA.getAsTemplateDecl(); TD && TD->isTypeAlias())
return TemplateDeductionResult::Success;
- // Perform template argument deduction for the template name.
- if (auto Result =
- DeduceTemplateArguments(S, TemplateParams, TNP, TNA, Info,
- SA->template_arguments(), Deduced);
- Result != TemplateDeductionResult::Success)
- return Result;
-
// FIXME: To preserve sugar, the TST needs to carry sugared resolved
// arguments.
ArrayRef<TemplateArgument> AResolved =
@@ -726,6 +719,12 @@ DeduceTemplateSpecArguments(Sema &S, TemplateParameterList *TemplateParams,
->castAs<TemplateSpecializationType>()
->template_arguments();
+ // Perform template argument deduction for the template name.
+ if (auto Result = DeduceTemplateArguments(S, TemplateParams, TNP, TNA, Info,
+ AResolved, Deduced);
+ Result != TemplateDeductionResult::Success)
+ return Result;
+
// Perform template argument deduction on each template
// argument. Ignore any missing/extra arguments, since they could be
// filled in by default arguments.
diff --git a/clang/test/SemaTemplate/cwg2398.cpp b/clang/test/SemaTemplate/cwg2398.cpp
index 45e74cce3a98c..f7f69e9d4268a 100644
--- a/clang/test/SemaTemplate/cwg2398.cpp
+++ b/clang/test/SemaTemplate/cwg2398.cpp
@@ -201,3 +201,19 @@ namespace consistency {
// new-error at -1 {{ambiguous partial specializations}}
} // namespace t2
} // namespace consistency
+
+namespace regression1 {
+ template <typename T, typename Y> struct map {};
+ template <typename T> class foo {};
+
+ template <template <typename...> class MapType, typename Value>
+ Value bar(MapType<int, Value> map);
+
+ template <template <typename...> class MapType, typename Value>
+ Value bar(MapType<int, foo<Value>> map);
+
+ void aux() {
+ map<int, foo<int>> input;
+ bar(input);
+ }
+} // namespace regression1
More information about the cfe-commits
mailing list