[clang] 85914b7 - [clang] fix regression deducing pack expansion arguments introduced by D110216

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 18 18:36:28 PST 2021


Author: Matheus Izvekov
Date: 2021-11-19T03:36:20+01:00
New Revision: 85914b757015dfbc780dc254696acb95b8dc7679

URL: https://github.com/llvm/llvm-project/commit/85914b757015dfbc780dc254696acb95b8dc7679
DIFF: https://github.com/llvm/llvm-project/commit/85914b757015dfbc780dc254696acb95b8dc7679.diff

LOG: [clang] fix regression deducing pack expansion arguments introduced by D110216

This test case had been missing when the original code
was introduced by 2fcb863b2b278.

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>

Differential Revision: https://reviews.llvm.org/D114207

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateDeduction.cpp
    clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 3c67b5b5072e..81edae10335d 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1337,6 +1337,13 @@ static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(
     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

diff  --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
index ec7e8970b1b5..bb7f9da58eda 100644
--- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
+++ b/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 @@ void test_h() {
   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 at -1 {{explicit instantiation of undefined function template 'map'}}
+
+} // namespace test_j


        


More information about the cfe-commits mailing list