aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e112621..9e40296 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8942,6 +8942,19 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
}
return NULL_TREE;
+ case INDIRECT_REF:
+ /* Fold *&X to X if X is an lvalue. */
+ if (TREE_CODE (op0) == ADDR_EXPR)
+ {
+ tree op00 = TREE_OPERAND (op0, 0);
+ if ((TREE_CODE (op00) == VAR_DECL
+ || TREE_CODE (op00) == PARM_DECL
+ || TREE_CODE (op00) == RESULT_DECL)
+ && !TREE_READONLY (op00))
+ return op00;
+ }
+ return NULL_TREE;
+
default:
return NULL_TREE;
} /* switch (code) */