diff options
-rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 51f21be64a8..a91c190cb0c 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -354,8 +354,9 @@ static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument( // 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(); diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp index d0fb25c047a..1a84d545c64 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp @@ -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 { |