c++: Fix bogus -Wparentheses warning [PR95344]
authorMarek Polacek <polacek@redhat.com>
Tue, 26 May 2020 23:59:26 +0000 (19:59 -0400)
committerMarek Polacek <polacek@redhat.com>
Fri, 29 May 2020 16:31:49 +0000 (12:31 -0400)
commit1f32d5294f51614f5637d81c522fccacc124f141
tree8ef2b8bc87d6962b86d876d723d929aa22fa928c
parent8e915901deb3518d4bef73ea52eab2ece7a2bbf6
c++: Fix bogus -Wparentheses warning [PR95344]

Since r267272, which added location wrappers, cp_fold loses
TREE_NO_WARNING on a MODIFY_EXPR that finish_parenthesized_expr set, and
that results in a bogus -Wparentheses warning.

I.e., previously we had "b = 1" but now we have "VIEW_CONVERT_EXPR<bool>(b) = 1"
and cp_fold_maybe_rvalue folds away the location wrapper and so we do
2718             x = fold_build2_loc (loc, code, TREE_TYPE (x), op0, op1);
in cp_fold and the flag is lost.

PR c++/95344
* cp-gimplify.c (cp_fold) <case MODIFY_EXPR>: Don't set
TREE_THIS_VOLATILE here.
(cp_fold): Set it here along with TREE_NO_WARNING.

* c-c++-common/Wparentheses-2.c: New test.
gcc/cp/cp-gimplify.c
gcc/testsuite/c-c++-common/Wparentheses-2.c [new file with mode: 0644]