r209190 - Fix diagnostic message for member function pointer mismatches where one of the

Richard Trieu rtrieu at google.com
Wed May 21 18:47:32 PDT 2014


On Tue, May 20, 2014 at 5:38 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Mon, May 19, 2014 at 9:10 PM, Richard Trieu <rtrieu at google.com> wrote:
>
>> Author: rtrieu
>> Date: Mon May 19 23:10:24 2014
>> New Revision: 209190
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=209190&view=rev
>> Log:
>> Fix diagnostic message for member function pointer mismatches where one
>> of the
>> classes is a template argument.
>>
>> Modified:
>>     cfe/trunk/lib/Sema/SemaOverload.cpp
>>     cfe/trunk/test/SemaCXX/err_init_conversion_failed.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=209190&r1=209189&r2=209190&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon May 19 23:10:24 2014
>> @@ -2526,7 +2526,8 @@ void Sema::HandleFunctionTypeMismatch(Pa
>>    if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) {
>>      const MemberPointerType *FromMember =
>> FromType->getAs<MemberPointerType>(),
>>                              *ToMember =
>> ToType->getAs<MemberPointerType>();
>> -    if (FromMember->getClass() != ToMember->getClass()) {
>> +    if (FromMember->getClass()->getCanonicalTypeInternal() !=
>> +        ToMember->getClass()->getCanonicalTypeInternal()) {
>>
>
> Please use Context.hasSameType or Context.hasSameUnqualifiedType as
> appropriate here, rather than calling an "Internal" function that does
> weird things with cv-qualifiers. (I think this is actually correct, because
> the class type is always unqualified here, but it's still better to use the
> higher-level interface.)
>

Fixed in r209378

>
>
>>        PDiag << ft_different_class << QualType(ToMember->getClass(), 0)
>>              << QualType(FromMember->getClass(), 0);
>>        return;
>>
>> Modified: cfe/trunk/test/SemaCXX/err_init_conversion_failed.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/err_init_conversion_failed.cpp?rev=209190&r1=209189&r2=209190&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/err_init_conversion_failed.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/err_init_conversion_failed.cpp Mon May 19
>> 23:10:24 2014
>> @@ -43,3 +43,19 @@ void test14(const float2 in, const float
>>    const float4 V = (float4){ in, out };
>>    // expected-error at -1{{cannot initialize a compound literal
>> initializer}}
>>  }
>> +
>> +namespace template_test {
>> +class S {
>> +public:
>> +   void foo(int);
>> +};
>> +
>> +template <class P> struct S2 {
>> +  void (P::*a)(const int &);
>> +};
>> +
>> +void test_15() {
>> +  S2<S> X = {&S::foo};
>> +  // expected-error at -1{{cannot initialize a member subobject of type
>> 'void (template_test::S::*)(const int &)' with an rvalue of type 'void
>> (template_test::S::*)(int)': type mismatch at 1st parameter ('const int &'
>> vs 'int')}}
>> +}
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140521/5df1012e/attachment.html>


More information about the cfe-commits mailing list