r183878 - Include the unexpanded packs in the initializer expression when checking a

Nick Lewycky nicholas at mxc.ca
Wed Jun 12 17:45:48 PDT 2013


Author: nicholas
Date: Wed Jun 12 19:45:47 2013
New Revision: 183878

URL: http://llvm.org/viewvc/llvm-project?rev=183878&view=rev
Log:
Include the unexpanded packs in the initializer expression when checking a
pack expanded constructor initializer list. Fixes PR16303!

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=183878&r1=183877&r2=183878&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Jun 12 19:45:47 2013
@@ -3165,8 +3165,9 @@ Sema::InstantiateMemInitializers(CXXCons
     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;

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp?rev=183878&r1=183877&r2=183878&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp Wed Jun 12 19:45:47 2013
@@ -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}}
+}





More information about the cfe-commits mailing list