From 98a75581e155a7dac853a69b0151960f8e2aacbd Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 13 Jun 2013 00:45:47 +0000 Subject: [PATCH] Include the unexpanded packs in the initializer expression when checking a 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 | 3 ++- test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 030b9c72c1..c947bcc9f2 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -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 Unexpanded; + SmallVector Unexpanded; collectUnexpandedParameterPacks(BaseTL, Unexpanded); + collectUnexpandedParameterPacks(Init->getInit(), Unexpanded); bool ShouldExpand = false; bool RetainExpansion = false; Optional NumExpansions; diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index 945379872f..218990e9bb 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -410,3 +410,14 @@ namespace WorkingPaperExample { f(h(args ...) + args ...); } } + +namespace PR16303 { + template struct A { A(int); }; + template struct B { + template struct C : A... { + C() : A(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}} +} -- 2.40.0