[cfe-commits] [Patch] Print differences for function pointers.

Richard Smith richard at metafoo.co.uk
Tue Nov 22 19:16:38 PST 2011


On Wed, November 23, 2011 03:01, Richard Trieu wrote:
> Mainly changes to diagnostic message wording.  Also switched the order on
> two types passed to a diagnostic.

Looks good to me, thanks!

Richard

> On Mon, Nov 21, 2011 at 4:02 PM, Richard Smith <richard at metafoo.co.uk>wrote:
>> On Mon, November 21, 2011 22:44, Richard Trieu wrote:
>>
>>> Ping.
>>>
>>
>> I've added a few more comments on the code review site.
>>
>>
>> Thanks,
>> Richard
>>
>>
>>> On Thu, Nov 17, 2011 at 12:45 PM, Matthieu Monrocq <
>>> matthieu.monrocq at gmail.com> wrote:
>>>
>>>>
>>>>
>>>> Le 17 novembre 2011 01:14, Richard Trieu <rtrieu at google.com> a écrit :
>>>>
>>>>
>>>>
>>>> On Wed, Nov 16, 2011 at 12:06 PM, Matthieu Monrocq <
>>>>
>>>>
>>>>> matthieu.monrocq at gmail.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> Le 15 novembre 2011 21:23, Richard Trieu <rtrieu at google.com> a
>>>>>> écrit
>> :
>>
>>>>>>
>>>>>>
>>>>>> New feature that will print additional information when
>>>>>> non-matching
>>>>>>
>>>>>>> function pointers are used.  This will help users more easily
>>>>>>> distinguish why the function pointers do not match.  The points
>>>>>>> of difference that will be noted are:
>>>>>>>
>>>>>>> Different number of parameters
>>>>>>> Different parameter type
>>>>>>> Different return type
>>>>>>> Different function qualifiers
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> For instance, code like this:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> double foo(int x) {return 0;}; double (*bar)(int, int) = &foo;
>>>>>>>
>>>>>>> Will get this error message:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> function-mismatch.cc:2:10: error: cannot initialize a variable of
>>>>>>>  type 'double (*)(int, int)' with an rvalue of type 'double
>>>>>>> (*)(int)'
>>>>>>> because of different number of parameters (expected 2 but has 1)
>> double
>>>>>>> (*bar)(int, int) = &foo;
>>>>>>> ^                ~~~~
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Patch is attached and also available at
>>>>>>> http://codereview.appspot.com/5369119/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Nice!
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> Do you plan on adding something for a difference of class (for
>>>>>> pointer to member functions) ? Or perhaps that it already exists...
>>>>>>
>>>>>> -- Matthieu
>>>>>>
>>>>>>
>>>>>>
>>>>>> Added a bit to the diagnostic message to say if they are from
>>>>>>
>> different
>>>>>>
>>>>> classes, as well as changes in response to comments Richard Smith
>>>>> made
>> on
>>>>> http://codereview.appspot.com/5369119/
>>>>>
>>>>>
>>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>>
>>>> -- Matthieu
>>>>
>>>>
>>>>
>>>
>>
>>
>




More information about the cfe-commits mailing list