aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-06-11 16:27:59 -0400
committerMarek Polacek <polacek@redhat.com>2020-06-11 16:27:59 -0400
commit4c07da7bec0c952e4918323222c2baa85f0a29f1 (patch)
tree8a6220dd13c0d3dbd4336973d7a4bf4727bfc78e /gcc/cp
parent18436d87ff85282b200579cb8da496659632ad6b (diff)
downloadgcc-4c07da7bec0c952e4918323222c2baa85f0a29f1.zip
gcc-4c07da7bec0c952e4918323222c2baa85f0a29f1.tar.gz
gcc-4c07da7bec0c952e4918323222c2baa85f0a29f1.tar.bz2
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/cp-gimplify.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index f326d71..0cf5bbb 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2675,8 +2675,6 @@ cp_fold (tree x)
else
x = org_x;
}
- if (code == MODIFY_EXPR && TREE_CODE (x) == MODIFY_EXPR)
- TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
break;
@@ -2932,6 +2930,12 @@ cp_fold (tree x)
return org_x;
}
+ if (EXPR_P (x) && TREE_CODE (x) == code)
+ {
+ TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
+ TREE_NO_WARNING (x) = TREE_NO_WARNING (org_x);
+ }
+
fold_cache->put (org_x, x);
/* Prevent that we try to fold an already folded result again. */
if (x != org_x)