This revision was not accepted when it landed; it landed in state "Needs
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85914b757015: [clang] fix regression deducing pack expansion
arguments introduced by D110216 (authored by mizvekov).
Changed prior to commit:
https://reviews.llvm.org/D114207?vs=388351&id=388362#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114207/new/
https://reviews.llvm.org/D114207
Files:
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
Index: clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
===================================================================
--- clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
+++ clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
// Note: Partial ordering of function templates containing template
// parameter packs is independent of the number of deduced arguments
@@ -26,3 +25,15 @@
double &dr1 = h((int(*)(int, float&))0);
double &dr2 = h((int(*)(int))0);
}
+
+namespace test_j {
+
+template <int I> struct ref {};
+
+template <int... L> void map(ref<L>...);
+template <int head, int... tail> void map(ref<head> x, ref<tail>... xs); //
expected-note {{here}}
+
+template void map<0, 1>(ref<0>, ref<1>);
+// expected-error@-1 {{explicit instantiation of undefined function template
'map'}}
+
+} // namespace test_j
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1337,6 +1337,13 @@
TemplateDeductionInfo &Info,
SmallVectorImpl<DeducedTemplateArgument> &Deduced, unsigned TDF,
bool PartialOrdering, bool DeducedFromArrayBound) {
+
+ // If the argument type is a pack expansion, look at its pattern.
+ // This isn't explicitly called out
+ if (const auto *AExp = dyn_cast<PackExpansionType>(A))
+ A = AExp->getPattern();
+ assert(!isa<PackExpansionType>(A.getCanonicalType()));
+
if (PartialOrdering) {
// C++11 [temp.deduct.partial]p5:
// Before the partial ordering is done, certain transformations are
Index: clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
===================================================================
--- clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
+++ clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
// Note: Partial ordering of function templates containing template
// parameter packs is independent of the number of deduced arguments
@@ -26,3 +25,15 @@
double &dr1 = h((int(*)(int, float&))0);
double &dr2 = h((int(*)(int))0);
}
+
+namespace test_j {
+
+template <int I> struct ref {};
+
+template <int... L> void map(ref<L>...);
+template <int head, int... tail> void map(ref<head> x, ref<tail>... xs); // expected-note {{here}}
+
+template void map<0, 1>(ref<0>, ref<1>);
+// expected-error@-1 {{explicit instantiation of undefined function template 'map'}}
+
+} // namespace test_j
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1337,6 +1337,13 @@
TemplateDeductionInfo &Info,
SmallVectorImpl<DeducedTemplateArgument> &Deduced, unsigned TDF,
bool PartialOrdering, bool DeducedFromArrayBound) {
+
+ // If the argument type is a pack expansion, look at its pattern.
+ // This isn't explicitly called out
+ if (const auto *AExp = dyn_cast<PackExpansionType>(A))
+ A = AExp->getPattern();
+ assert(!isa<PackExpansionType>(A.getCanonicalType()));
+
if (PartialOrdering) {
// C++11 [temp.deduct.partial]p5:
// Before the partial ordering is done, certain transformations are
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits