]> granicus.if.org Git - clang/commitdiff
Include the unexpanded packs in the initializer expression when checking a
authorNick Lewycky <nicholas@mxc.ca>
Thu, 13 Jun 2013 00:45:47 +0000 (00:45 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 13 Jun 2013 00:45:47 +0000 (00:45 +0000)
pack expanded constructor initializer list. Fixes PR16303!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183878 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/CXX/temp/temp.decls/temp.variadic/p5.cpp

index 030b9c72c1ceb090c2ebd00365c792b50cf1faf1..c947bcc9f2a060a51c9f79e1ee70d22c0db21d2e 100644 (file)
@@ -3165,8 +3165,9 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
     if (Init->isPackExpansion()) {
       // This is a pack expansion. We should expand it now.
       TypeLoc BaseTL = Init->getTypeSourceInfo()->getTypeLoc();
-      SmallVector<UnexpandedParameterPack, 2> Unexpanded;
+      SmallVector<UnexpandedParameterPack, 4> Unexpanded;
       collectUnexpandedParameterPacks(BaseTL, Unexpanded);
+      collectUnexpandedParameterPacks(Init->getInit(), Unexpanded);
       bool ShouldExpand = false;
       bool RetainExpansion = false;
       Optional<unsigned> NumExpansions;
index 945379872f78d11b57a203b493f0dff98299230e..218990e9bb32478179b7ee865b9be58e437182e3 100644 (file)
@@ -410,3 +410,14 @@ namespace WorkingPaperExample {
     f(h(args ...) + args ...);
   }
 }
+
+namespace PR16303 {
+  template<int> struct A { A(int); };
+  template<int...N> struct B {
+    template<int...M> struct C : A<N>... {
+      C() : A<N>(M)... {} // expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (2 vs. 3)}} expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (4 vs. 3)}}
+    };
+  };
+  B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}}
+  B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}}
+}