diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-05-17 06:45:49 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-05-17 06:45:49 +0000 |
commit | 00600cb7f436e8e18c9ab325013a203e4cecc1d4 (patch) | |
tree | 7e09f8f4c9c5be93dea3e3b6573f3da476b0833b /gcc/c-typeck.c | |
parent | 17c3cca00027e9cb18296796c2e009a328620bf9 (diff) |
PR tree-optimization/21610
* c-typeck.c (decl_constant_value_for_broken_optimization): If not
returning DECL, call unshare_expr.
* gcc.c-torture/compile/20050516-1.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@99815 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 806a20ade96..b96328d89b9 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1249,10 +1249,18 @@ decl_constant_value (tree decl) static tree decl_constant_value_for_broken_optimization (tree decl) { + tree ret; + if (pedantic || DECL_MODE (decl) == BLKmode) return decl; - else - return decl_constant_value (decl); + + ret = decl_constant_value (decl); + /* Avoid unwanted tree sharing between the initializer and current + function's body where the tree can be modified e.g. by the + gimplifier. */ + if (ret != decl && TREE_STATIC (decl)) + ret = unshare_expr (ret); + return ret; } |