[C++ PATCH] Do not warn about zero-as-null when NULL is used.

Jason Merrill jason@redhat.com
Wed May 30 15:32:00 GMT 2018


On Wed, May 30, 2018 at 5:24 AM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> On 29 May 2018 at 23:43, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
>> Another round. The other occurrence of maybe_warn_zero_as_null_pointer_constant
>> in typeck.c seems superfluous. The one in cvt.c seems necessary for
>> cpp0x/Wzero-as-null* tests. It seems like cp_build_binary_op is far more suited
>> to check the EQ_EXPR/NE_EXPR cases than conversion_null_warnings is.
>>
>> Tested manually on Linux-x64, running full suite on Linux-PPC64. Ok for trunk?
>>
>> 2018-05-29  Ville Voutilainen  <ville.voutilainen@gmail.com>
>>
>>     gcc/cp/
>>
>>     Do not warn about zero-as-null when NULL is used.
>>     * typeck.c (cp_build_binary_op): Diagnose zero as null here..
>>     * call.c (conversion_null_warnings): ..and here..
>>     * cvt.c (cp_convert_to_pointer): ..not here.
>>
>>     testsuite/
>>
>>     Do not warn about zero-as-null when NULL is used.
>>     * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New.
>
> If we want, we can fine-tune conversion_null_warnings to not bother
> with the source location if we don't call maybe_warn, thus.

Hmm, why doesn't maybe_warn_zero_as_null_pointer_constant check
null_node_p like it does NULLPTR_TYPE_P?

Jason



More information about the Gcc-patches mailing list