This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-in-cxx update
Richard Guenther <richard.guenther@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