[PATCH] c, c++: Fix up -Wunused-value on COMPLEX_EXPRs [PR97748]
Tue Nov 10 14:32:15 GMT 2020
On 11/10/20 3:48 AM, Jakub Jelinek wrote:
> On Mon, Nov 09, 2020 at 10:34:00PM +0100, Jakub Jelinek via Gcc-patches wrote:
>> On Mon, Nov 09, 2020 at 02:35:58PM -0500, Jason Merrill wrote:
>>> How about calling warn_if_unused_value instead of the new
>> That seems to work if I just replace the warning_at call with
>> warn_if_unused_value call (at least no regression in check-c++-all and
>> libstdc++ testsuite).
>> Initially I've tried just calling warn_if_unused_value without the NOP_EXPR
>> stripping and code/tclass checks, but that regressed a few tests, e.g.
>> g++.dg/warn/Wunused-14.C or c-c++-common/Wunused-var-9.c or 3 lines
>> in the new test, e.g. because STATEMENT_LIST or CLEANUP_POINT_EXPRs would
>> make it through and resulted in bogus warnings.
> Bootstrapped/regtested on x86_64-linux and i686-linux successfully now.
> If we wanted to simplify, I think the && !(code == ....) part could be
> dropped too, i.e. just
> if (tclass == tcc_comparison
> || tclass == tcc_unary
> || tclass == tcc_binary
> || code == VEC_PERM_EXPR
> || code == VEC_COND_EXPR)
> warn_if_unused_value (e, loc);
> because warn_if_unused_value already returns false on those codes.
OK with that change.
More information about the Gcc-patches