]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: more ahead-of-time -Wparentheses warnings
authorPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:14:04 +0000 (11:14 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:14:04 +0000 (11:14 -0400)
commit0f2e2080685e75097c319e83eae4776fa98edd01
tree0c219646bb2d141ea9c041b5f51e9ac19b766b0b
parente5f6a5ad7ceece5238fc3d63f7ea92574df4264d
c++: more ahead-of-time -Wparentheses warnings

Now that we don't have to worry about looking through NON_DEPENDENT_EXPR,
we can easily extend the -Wparentheses warning in convert_for_assignment
to consider (non-dependent) templated assignment operator expressions as
well, like r14-4111-g6e92a6a2a72d3b did in maybe_convert_cond.

gcc/cp/ChangeLog:

* cp-tree.h (maybe_warn_unparenthesized_assignment): Declare.
* semantics.cc (is_assignment_op_expr_p): Generalize to return
true for any assignment operator expression, not just one that
has been resolved to an operator overload.
(maybe_warn_unparenthesized_assignment): Factored out from ...
(maybe_convert_cond): ... here.
(finish_parenthesized_expr): Mention
maybe_warn_unparenthesized_assignment.
* typeck.cc (convert_for_assignment): Replace -Wparentheses
warning logic with maybe_warn_unparenthesized_assignment.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wparentheses-13.C: Strengthen by expecting that
we issue the -Wparentheses warnings ahead of time.
* g++.dg/warn/Wparentheses-23.C: Likewise.
* g++.dg/warn/Wparentheses-32.C: Remove xfails.
gcc/cp/cp-tree.h
gcc/cp/semantics.cc
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/warn/Wparentheses-13.C
gcc/testsuite/g++.dg/warn/Wparentheses-23.C
gcc/testsuite/g++.dg/warn/Wparentheses-32.C