aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorZhao Wei Liew <zhaoweiliew@gmail.com>2022-02-15 17:44:29 +0800
committerJason Merrill <jason@redhat.com>2022-04-28 22:57:54 -0400
commit654f6978cdc85a3970ff2c478d4df3e55cf4d3ab (patch)
tree0fc2caf7ab45e3612473ca30b0f76b852fa6ee9c /gcc/value-range.h
parent6b6f53d8afdb3744530a93e1f8dc00de69052493 (diff)
downloadgcc-654f6978cdc85a3970ff2c478d4df3e55cf4d3ab.zip
gcc-654f6978cdc85a3970ff2c478d4df3e55cf4d3ab.tar.gz
gcc-654f6978cdc85a3970ff2c478d4df3e55cf4d3ab.tar.bz2
c++: Add diagnostic when operator= is used as truth cond [PR25689]
When compiling the following code with g++ -Wparentheses, GCC does not warn on the if statement. For example, there is no warning for this code: struct A { A& operator=(int); operator bool(); }; void f(A a) { if (a = 0); // no warning } This is because a = 0 is a call to operator=, which GCC does not handle. This patch fixes this issue by handling calls to operator= when deciding to warn. Bootstrapped and regression tested on x86_64-pc-linux-gnu. PR c++/25689 gcc/cp/ChangeLog: * call.cc (extract_call_expr): Return a NULL_TREE on failure instead of asserting. (build_new_method_call): Suppress -Wparentheses diagnostic for MODIFY_EXPR. * semantics.cc (is_assignment_op_expr_p): Add function to check if an expression is a call to an op= operator expression. (maybe_convert_cond): Handle the case of a op= operator expression for the -Wparentheses diagnostic. gcc/testsuite/ChangeLog: * g++.dg/warn/Wparentheses-31.C: New test. Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
Diffstat (limited to 'gcc/value-range.h')
0 files changed, 0 insertions, 0 deletions