diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-01-13 13:31:13 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-01-13 13:31:13 +0000 |
commit | a9b39de805384725f09b3b80c928bdf8aeca8d1f (patch) | |
tree | 53f4a546ee8865499b7d85bcfaf0e4d567e56007 /gcc/fold-const.c | |
parent | c63fbb8acda50e64d7ca83000caf5739b7e1f163 (diff) | |
download | gcc-a9b39de805384725f09b3b80c928bdf8aeca8d1f.tar.gz |
2010-01-13 Richard Guenther <rguenther@suse.de>
PR middle-end/42716
* fold-const.c (fold_unary_loc): Fold INDIRECT_REFs.
* gcc.c-torture/compile/pr42716.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155859 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e1126219689..9e40296123c 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) */ |