On 10/08/16 19:40, Jason Merrill wrote:
> On Fri, Sep 30, 2016 at 1:07 AM, Bernd Edlinger
> <[email protected]> wrote:
>> On 09/29/16 22:38, Jason Merrill wrote:
>>> On Thu, Sep 29, 2016 at 3:58 PM, Bernd Edlinger
>>> <[email protected]> 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 ?
>
> Done thus:
>
Thanks.
But I have one question:
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2253,6 +2253,15 @@ cp_fold (tree x)
op1 = cp_fold (TREE_OPERAND (x, 1));
op2 = cp_fold (TREE_OPERAND (x, 2));
+ if (TREE_CODE (TREE_TYPE (x)) == BOOLEAN_TYPE)
+ {
+ warning_sentinel (warn_int_in_bool_context);
Yes, it compiles, but ...
how can this compile at all?
Doesn't it miss a name of a local?
like warning_sentinel c (warn_int_in_bool_context);
If I disassemble this function I see a constructor of
warning_sentinel directly followed by a destuctor.
And apparently warn_int_in_bool_context is not zero
in the block, thus:
if (TREE_CODE (TREE_TYPE (x)) == BOOLEAN_TYPE)
{
warning_sentinel (warn_int_in_bool_context);
gcc_assert (!warn_int_in_bool_context);
if (!VOID_TYPE_P (TREE_TYPE (op1)))
op1 = cp_truthvalue_conversion (op1);
fails the assertion.
Bernd.