]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/24172 (error: incorrect sharing of tree nodes)
authorJan Hubicka <jh@suse.cz>
Sun, 30 Oct 2005 18:14:15 +0000 (19:14 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 30 Oct 2005 18:14:15 +0000 (18:14 +0000)
PR tree-optimization/24172
* tree-inline.c (copy_body_r): Unshare the substituted value first.
* g++.dg/tree-ssa/pr24172.C: New testcase.

From-SVN: r106247

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr24172.C [new file with mode: 0644]
gcc/tree-inline.c

index 4eb8a407473896b168b61af375d4503761ed79cb..56ab4272dcbc5e4c6c4e0879e94b3ddcef6cda67 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-30  Jan Hubicka  <jh@suse.cz>
+
+       PR tree-optimization/24172
+       * tree-inline.c (copy_body_r): Unshare the substituted value first.
+
 2005-10-30  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * config/mmix/mmix.c (mmix_intval): Correct handling of DFmode
index 09b9ada1629b5ea631575aabc7b523dd8630460b..26acd54f9ceb8b366fd935475f93806c0fb19dbf 100644 (file)
@@ -1,3 +1,7 @@
+2005-10-30  Jan Hubicka  <jh@suse.cz>
+
+       * g++.dg/tree-ssa/pr24172.C: New testcase.
+
 2005-10-30  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.dg/enum_10.f90, gfortran.dg/enum_10.c: New test.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24172.C b/gcc/testsuite/g++.dg/tree-ssa/pr24172.C
new file mode 100644 (file)
index 0000000..245186a
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-options "-O2" }
+void IOException( char);
+inline int* dummy( const char* const mode )
+{
+  IOException(*mode+*mode);
+}
+
+void prepare_inpaint( )
+{
+  dummy ("rb");
+}
index 0f7ea978b7221c0624d8de39fd58e90d2259bb6c..228252fd7090ba6a0cc2c59b49c6c045694968fb 100644 (file)
@@ -639,6 +639,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
          n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
          if (n)
            {
+             tree new;
              /* If we happen to get an ADDR_EXPR in n->value, strip
                 it manually here as we'll eventually get ADDR_EXPRs
                 which lie about their types pointed to.  In this case
@@ -646,13 +647,14 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
                 but we absolutely rely on that.  As fold_indirect_ref
                 does other useful transformations, try that first, though.  */
              tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
-             *tp = fold_indirect_ref_1 (type, (tree)n->value);
+             new = unshare_expr ((tree)n->value);
+             *tp = fold_indirect_ref_1 (type, new);
              if (! *tp)
                {
-                 if (TREE_CODE ((tree)n->value) == ADDR_EXPR)
-                   *tp = TREE_OPERAND ((tree)n->value, 0);
+                 if (TREE_CODE (new) == ADDR_EXPR)
+                   *tp = TREE_OPERAND (new, 0);
                  else
-                   *tp = build1 (INDIRECT_REF, type, (tree)n->value);
+                   *tp = build1 (INDIRECT_REF, type, new);
                }
              *walk_subtrees = 0;
              return NULL;
This page took 0.090421 seconds and 5 git commands to generate.