forked from OSchip/llvm-project
[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. llvm-svn: 319584
This commit is contained in:
parent
6260cf71d3
commit
7bfcc05830
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue