aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-11-10 15:56:20 +0100
committerJakub Jelinek <jakub@redhat.com>2020-11-10 15:56:20 +0100
commit0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 (patch)
treeea86e5aadf8bd224dbbdbaf8d0aea40a784e69b3 /libgcc
parent1693746302e4306b43cb66a0afe589137069bd8e (diff)
downloadgcc-0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739.zip
gcc-0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739.tar.gz
gcc-0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739.tar.bz2
c, c++: Fix up -Wunused-value on COMPLEX_EXPRs [PR97748]
The -Wunused-value warning in both C and C++ FEs (implemented significantly differently between the two) sees the COMPLEX_EXPRs created e.g. for complex pre/post increment and many other expressions as useless and warns about it. For the C warning implementation, on e.g. COMPLEX_EXPR < ++REALPART_EXPR <x>, IMAGPART_EXPR <x>>; would warn even on the IMAGPART_EXPR <x> there alone etc., so what works is check if we'd warn about both operands of COMPLEX_EXPR and if yes, warn on the whole COMPLEX_EXPR, otherwise don't warn. The C++ warning implementation is significantly different and for that one the only warn if both would be warned about doesn't really work, we then miss warnings e.g. about COMPLEX_EXPR <REALPART_EXPR <SAVE_EXPR <x>> + 1.0e+0, IMAGPART_EXPR <SAVE_EXPR <x>>> >>>>> The patch replaces the warning_at call with call to the c-family warn_if_unused_value function. On the testcase which after the initial new tests contains pretty much everything from gcc.dg/Wunused-value-1.c both approaches seem to work nicely. 2020-11-10 Jakub Jelinek <jakub@redhat.com> PR c/97748 gcc/c-family/ * c-common.h (warn_if_unused_value): Add quiet argument defaulted to false. * c-warn.c (warn_if_unused_value): Likewise. Pass it down recursively and just return true instead of warning if it is true. Handle COMPLEX_EXPR. gcc/cp/ * cvt.c (convert_to_void): Check (complain & tf_warning) in the outer if rather than twice times in the inner one. Use warn_if_unused_value. Formatting fix. gcc/testsuite/ * c-c++-common/Wunused-value-1.c: New test.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions