aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-10-04 14:34:06 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-10-04 14:34:06 +0200
commitf548a3173e47b45bf132c533091c8776ca79b629 (patch)
treee03429ddfdb28c26c0b8a6b943ec84b3196db8b1 /gcc/fold-const.c
parent8cba60274732940251f0cd65af9f2d3b6f7b7e18 (diff)
downloadgcc-f548a3173e47b45bf132c533091c8776ca79b629.zip
gcc-f548a3173e47b45bf132c533091c8776ca79b629.tar.gz
gcc-f548a3173e47b45bf132c533091c8776ca79b629.tar.bz2
fold-const.c (fold_unary_loc): Don't optimize POINTER_PLUS_EXPR casted to TYPE_RESTRICT pointer by casting the...
* fold-const.c (fold_unary_loc): Don't optimize POINTER_PLUS_EXPR casted to TYPE_RESTRICT pointer by casting the inner pointer if it isn't TYPE_RESTRICT. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't through casts from non-TYPE_RESTRICT pointer to TYPE_RESTRICT pointer. * gcc.dg/tree-ssa/restrict-4.c: New test. From-SVN: r179500
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 79ebd8b..c3871f1 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7946,6 +7946,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
that this happens when X or Y is NOP_EXPR or Y is INTEGER_CST. */
if (POINTER_TYPE_P (type)
&& TREE_CODE (arg0) == POINTER_PLUS_EXPR
+ && (!TYPE_RESTRICT (type) || TYPE_RESTRICT (TREE_TYPE (arg0)))
&& (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
|| TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
|| TREE_CODE (TREE_OPERAND (arg0, 1)) == NOP_EXPR))