forked from OSchip/llvm-project
[MS Compat] Adjust thiscall to cdecl when deducing template arguments
Function types can be extracted from member pointer types. However, the type is not appropriate without first adjusting the calling convention. This fixes PR25661. llvm-svn: 254323
This commit is contained in:
parent
1be692ecdb
commit
a381cda78c
|
@ -1517,10 +1517,19 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S,
|
|||
if (!MemPtrArg)
|
||||
return Sema::TDK_NonDeducedMismatch;
|
||||
|
||||
QualType ParamPointeeType = MemPtrParam->getPointeeType();
|
||||
if (ParamPointeeType->isFunctionType())
|
||||
S.adjustMemberFunctionCC(ParamPointeeType, /*IsStatic=*/true,
|
||||
/*IsCtorOrDtor=*/false, Info.getLocation());
|
||||
QualType ArgPointeeType = MemPtrArg->getPointeeType();
|
||||
if (ArgPointeeType->isFunctionType())
|
||||
S.adjustMemberFunctionCC(ArgPointeeType, /*IsStatic=*/true,
|
||||
/*IsCtorOrDtor=*/false, Info.getLocation());
|
||||
|
||||
if (Sema::TemplateDeductionResult Result
|
||||
= DeduceTemplateArgumentsByTypeMatch(S, TemplateParams,
|
||||
MemPtrParam->getPointeeType(),
|
||||
MemPtrArg->getPointeeType(),
|
||||
ParamPointeeType,
|
||||
ArgPointeeType,
|
||||
Info, Deduced,
|
||||
TDF & TDF_IgnoreQualifiers))
|
||||
return Result;
|
||||
|
|
|
@ -370,6 +370,19 @@ X<fun_cdecl >::p tmpl6 = &A::method_thiscall;
|
|||
X<fun_stdcall >::p tmpl7 = &A::method_stdcall;
|
||||
X<fun_fastcall>::p tmpl8 = &A::method_fastcall;
|
||||
|
||||
// Make sure we adjust thiscall to cdecl when extracting the function type from
|
||||
// a member pointer.
|
||||
template <typename> struct Y;
|
||||
|
||||
template <typename Fn, typename C>
|
||||
struct Y<Fn C::*> {
|
||||
typedef Fn *p;
|
||||
};
|
||||
|
||||
void __cdecl f_cdecl();
|
||||
Y<decltype(&A::method_thiscall)>::p tmpl9 = &f_cdecl;
|
||||
|
||||
|
||||
} // end namespace MemberPointers
|
||||
|
||||
// Test that lambdas that capture nothing convert to cdecl function pointers.
|
||||
|
|
Loading…
Reference in New Issue