r254323 - [MS Compat] Adjust thiscall to cdecl when deducing template arguments

NAKAMURA Takumi via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 30 15:51:23 PST 2015


You forgot to update test/CXX/drs/dr5xx.cpp. Updated in r254346.

On Tue, Dec 1, 2015 at 5:37 AM David Majnemer via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: majnemer
> Date: Mon Nov 30 14:34:28 2015
> New Revision: 254323
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254323&view=rev
> Log:
> [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.
>
> Modified:
>     cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>     cfe/trunk/test/SemaCXX/calling-conv-compat.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=254323&r1=254322&r2=254323&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Nov 30 14:34:28 2015
> @@ -1517,10 +1517,19 @@ DeduceTemplateArgumentsByTypeMatch(Sema
>        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;
>
> Modified: cfe/trunk/test/SemaCXX/calling-conv-compat.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/calling-conv-compat.cpp?rev=254323&r1=254322&r2=254323&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/calling-conv-compat.cpp (original)
> +++ cfe/trunk/test/SemaCXX/calling-conv-compat.cpp Mon Nov 30 14:34:28 2015
> @@ -370,6 +370,19 @@ X<fun_cdecl   >::p tmpl6 = &A::method_th
>  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.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151130/6d543a18/attachment.html>


More information about the cfe-commits mailing list