aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-05-17 08:45:49 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2005-05-17 08:45:49 +0200
commitc477e13bd7d3f369cde2fbb171d8aa9501759373 (patch)
tree7e09f8f4c9c5be93dea3e3b6573f3da476b0833b /gcc
parent22c3c0917f67402389deb1e877c429f93a6a0b38 (diff)
downloadgcc-c477e13bd7d3f369cde2fbb171d8aa9501759373.zip
gcc-c477e13bd7d3f369cde2fbb171d8aa9501759373.tar.gz
gcc-c477e13bd7d3f369cde2fbb171d8aa9501759373.tar.bz2
re PR tree-optimization/21610 (ICE in make_decl_rtl)
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. From-SVN: r99815
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-typeck.c12
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20050516-1.c12
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7bab281..99e0108 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/21610
+ * c-typeck.c (decl_constant_value_for_broken_optimization): If not
+ returning DECL, call unshare_expr.
+
2005-05-17 Hans-Peter Nilsson <hp@axis.com>
* config/cris/cris.md: Unquote preparation and output statements.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 806a20a..b96328d 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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2e99a36..e691174 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2005-05-17 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/21610
+ * gcc.c-torture/compile/20050516-1.c: New test.
+
PR fortran/15080
* gfortran.fortran-torture/execute/forall_3.f90: Remove comment
about the test failing.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050516-1.c b/gcc/testsuite/gcc.c-torture/compile/20050516-1.c
new file mode 100644
index 0000000..2cdf696
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20050516-1.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/21610 */
+
+struct S { char s; };
+struct T { struct S t; };
+
+struct S *const p = &((struct T * const) (0x4000))->t;
+
+void
+foo (void)
+{
+ p->s = 0;
+}