This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCHv2] Add a warning for invalid function casts


On Thu, Nov 30, 2017 at 10:14 AM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> On 11/29/17 22:57, Jason Merrill wrote:
>> On 10/09/2017 06:30 PM, Bernd Edlinger wrote:

>>> +  if (INTEGRAL_TYPE_P (t1)
>>> +      && INTEGRAL_TYPE_P (t2)
>>> +      && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
>>> +      && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
>>> +      || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
>>> +    return true;
>>
>> This section needs a comment explaining what you're allowing and why.
>
> Okay. I will add a comment here:
>
>    /* The signedness of the parameter matters only when an integral
>       type smaller than int is promoted to int, otherwise only the
>       precision of the parameter matters.
>       This check should make sure that the callee does not see
>       undefined values in argument registers.  */

If we're thinking about argument promotion, should this use
type_passed_as rather than assume promotion to int?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]