Author: rsmith Date: Fri Dec 1 13:24:36 2017 New Revision: 319584 URL: http://llvm.org/viewvc/llvm-project?rev=319584&view=rev Log: [c++17] When deducing the type of a non-type template parameter from the type of its argument, perform function-to-pointer and array-to-pointer decay on the parameter type first.
Otherwise deduction will fail, as the type of the argument will be decayed. Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=319584&r1=319583&r2=319584&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Dec 1 13:24:36 2017 @@ -354,8 +354,9 @@ static Sema::TemplateDeductionResult Ded // expanded NTTP should be a pack expansion type? return Sema::TDK_Success; - // Get the type of the parameter for deduction. - QualType ParamType = NTTP->getType(); + // Get the type of the parameter for deduction. If it's a (dependent) array + // or function type, we will not have decayed it yet, so do that now. + QualType ParamType = S.Context.getAdjustedParameterType(NTTP->getType()); if (auto *Expansion = dyn_cast<PackExpansionType>(ParamType)) ParamType = Expansion->getPattern(); 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=319584&r1=319583&r2=319584&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp (original) +++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Fri Dec 1 13:24:36 2017 @@ -238,6 +238,10 @@ namespace Auto { constexpr char s[] = "test"; template<const auto* p> struct S { }; S<s> p; + + template<typename R, typename P, R F(P)> struct A {}; + template<typename R, typename P, R F(P)> void x(A<R, P, F> a); + void g(int) { x(A<void, int, &g>()); } } namespace DecltypeAuto { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits