[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:
David Majnemer 2015-11-30 20:34:28 +00:00
parent 1be692ecdb
commit a381cda78c
2 changed files with 24 additions and 2 deletions

View File

@ -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;

View File

@ -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.