diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-07-17 20:57:54 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-07-17 20:57:54 -0400 |
commit | 144b6099cdaa9ac1b298687c0cfdb06a970e338b (patch) | |
tree | 4b893361f04c94d02c8977459bf20dc1c70a07ac /gcc/cp | |
parent | 313afcfdabeab3e6705ac0bd1273627075be0023 (diff) | |
download | gcc-144b6099cdaa9ac1b298687c0cfdb06a970e338b.zip gcc-144b6099cdaa9ac1b298687c0cfdb06a970e338b.tar.gz gcc-144b6099cdaa9ac1b298687c0cfdb06a970e338b.tar.bz2 |
c++: missing -Wunused-value for !<expr> [PR114104]
Here we're neglecting to issue a -Wunused-value warning for suitable !
operator expressions, and in turn for != operator expressions that are
rewritten as !(x == y), only because we don't call warn_if_unused_value
on TRUTH_NOT_EXPR since its class is tcc_expression. This patch makes
us also consider warning for TRUTH_NOT_EXPR and also for ADDR_EXPR.
PR c++/114104
gcc/cp/ChangeLog:
* cvt.cc (convert_to_void): Call warn_if_unused_value for
TRUTH_NOT_EXPR and ADDR_EXPR as well.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wunused-20.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cvt.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc index db086c0..d95e01c 100644 --- a/gcc/cp/cvt.cc +++ b/gcc/cp/cvt.cc @@ -1664,6 +1664,8 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) if (tclass == tcc_comparison || tclass == tcc_unary || tclass == tcc_binary + || code == TRUTH_NOT_EXPR + || code == ADDR_EXPR || code == VEC_PERM_EXPR || code == VEC_COND_EXPR) warn_if_unused_value (e, loc); |