Author: rsmith Date: Sun Jun 23 22:53:11 2019 New Revision: 364165 URL: http://llvm.org/viewvc/llvm-project?rev=364165&view=rev Log: PR42362: Fix auto deduction of template parameter packs from type-dependent argument packs.
We need to strip off the PackExpansionExpr to get the real (dependent) type rather than an opaque DependentTy. Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=364165&r1=364164&r2=364165&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Jun 23 22:53:11 2019 @@ -6323,9 +6323,12 @@ ExprResult Sema::CheckTemplateArgument(N // the type is dependent, in order to check the types of non-type template // arguments line up properly in partial ordering. Optional<unsigned> Depth = Param->getDepth() + 1; + Expr *DeductionArg = Arg; + if (auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg)) + DeductionArg = PE->getPattern(); if (DeduceAutoType( Context.getTrivialTypeSourceInfo(ParamType, Param->getLocation()), - Arg, ParamType, Depth) == DAR_Failed) { + DeductionArg, ParamType, Depth) == DAR_Failed) { Diag(Arg->getExprLoc(), diag::err_non_type_template_parm_type_deduction_failure) << Param->getDeclName() << Param->getType() << Arg->getType() Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp?rev=364165&r1=364164&r2=364165&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp (original) +++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Sun Jun 23 22:53:11 2019 @@ -378,3 +378,18 @@ template <class T> struct M { } }; } + +namespace PR42362 { + template<auto ...A> struct X { struct Y; void f(int...[A]); }; + template<auto ...A> struct X<A...>::Y {}; + template<auto ...A> void X<A...>::f(int...[A]) {} + void f() { X<1, 2>::Y y; X<1, 2>().f(0, 0); } + + template<typename, auto...> struct Y; + template<auto ...A> struct Y<int, A...> {}; + Y<int, 1, 2, 3> y; + + template<auto (&...F)()> struct Z { struct Q; }; + template<auto (&...F)()> struct Z<F...>::Q {}; + Z<f, f, f>::Q q; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits