Richard Guenther <richard.guent...@gmail.com> writes:

>> * The C++ frontend emits some warnings on code which is known to be
>>  never executed, which the C frontend does not.  This leads to some
>>  warnings compiling code in gcc.  I think it is reasonable to fix this
>>  in the C++ frontend.
>
> Or just amend the C frontend to also warn in these cases?

We could do that, but we would have to adjust gcc's code base to avoid
the warnings.  For example, in insn-modes.c we emit code like this:

#define MODE_MASK(m)                          \
  ((m) >= HOST_BITS_PER_WIDE_INT)             \
   ? ~(unsigned HOST_WIDE_INT) 0              \
   : ((unsigned HOST_WIDE_INT) 1 << (m)) - 1

  MODE_MASK (0),           /* VOID */

With the current C++ frontend, this issues a warning about a shift
larger than the word size.  The C frontend sees that the condition is a
constant, so it does not issue any warnings about the unexecuted side of
the conditional.  This is done by manipulating skip_evaluation in
c_parser_conditional_expression and testing it in build_binary_op.

Ian

Reply via email to