This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops
- From: Jason Merrill <jason at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Florian Weimer <fw at deneb dot enyo dot de>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>
- Date: Sun, 2 Oct 2016 14:38:05 -0400
- Subject: Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops
- Authentication-results: sourceware.org; auth=none
- References: <AM4PR0701MB2162CF4DE9EAAFFE605F4BB0E4CA0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <87shslv769.fsf@mid.deneb.enyo.de> <HE1PR0701MB216982AD7458FB1E5244360AE4CC0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <87fuol77ri.fsf@mid.deneb.enyo.de> <HE1PR0701MB21694CB05881916BDFF3A251E4CC0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <CADzB+2n085rFdKy5AQuffwjnGOYMdR0zNzbbKJGJT+KrXUdFHA@mail.gmail.com> <HE1PR0701MB21692B89F7F6754AB32594EEE4CC0@HE1PR0701MB2169.eurprd07.prod.outlook.com> <CADzB+2=pWuj6AUQFKAbc=f+pq616+Gx6tCNwzPU_e4Dp84PY4g@mail.gmail.com> <AM4PR0701MB2162EC708CAF70C79B380A62E4CF0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <CADzB+2kzJk5N5RctXS_SM1b2FKH8R8hAkbXK7RxzEtNaD2iqPg@mail.gmail.com> <AM4PR0701MB216289DC52D6AA7A184F9821E4CE0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <AM4PR0701MB2162D459F858784668E47F78E4CE0@AM4PR0701MB2162.eurprd07.prod.outlook.com> <CADzB+2k9EFRaS3AzppHBsT-hSaYgMy4qTKCVviFbVGcBV2V7iw@mail.gmail.com> <AM4PR0701MB216221175254CF5C35B6D372E4C10@AM4PR0701MB2162.eurprd07.prod.outlook.com>
OK.
On Fri, Sep 30, 2016 at 1:07 AM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> On 09/29/16 22:38, Jason Merrill wrote:
>> On Thu, Sep 29, 2016 at 3:58 PM, Bernd Edlinger
>> <bernd.edlinger@hotmail.de> wrote:
>>> Unfortunately, without that exception there is a false positive:
>>>
>>> In file included from ../../gcc-trunk/gcc/ada/gcc-interface/decl.c:30:0:
>>> ../../gcc-trunk/gcc/ada/gcc-interface/decl.c: In function 'int
>>> adjust_packed(tree, tree, int)':
>>> ../../gcc-trunk/gcc/tree.h:1874:22: error: << on signed integer in
>>> boolean context [-Werror=int-in-bool-context]
>>> ? ((unsigned)1) << ((NODE)->type_common.align - 1) : 0)
>>> ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Ah, this issue again: the shift isn't in boolean context, it's in
>> integer context. I think we want to be a lot more conservative about
>> these warnings in the arms of a COND_EXPR. In fact, I think the
>> entire
>>
>> /* Distribute the conversion into the arms of a COND_EXPR. */
>>
>> section is wrong now that we're doing delayed folding.
>>
>
> Could you take care of this ?
>
>
> For the warning, I think I can suppress it just while
> the recursing into the condition arms.
>
> As in this updated patch.
>
> Is it OK?
>
>
> Bernd.