]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/42625 (-fipa-sra can generate different destructors in differ...
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jan 2010 15:10:26 +0000 (16:10 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jan 2010 15:10:26 +0000 (16:10 +0100)
PR tree-optimization/42625
* cgraph.c (cgraph_make_node_local): Clear DECL_COMDAT*,
TREE_PUBLIC, DECL_WEAK and DECL_EXTERNAL also for same_body
aliases.

* g++.dg/opt/dtor4.C: New test.
* g++.dg/opt/dtor4.h: New.
* g++.dg/opt/dtor4-aux.cc: New.

From-SVN: r155694

gcc/ChangeLog
gcc/cgraph.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/dtor4-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/dtor4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/dtor4.h [new file with mode: 0644]

index 4bf1274a94352ec3da1586e83631e997ff386b9e..77620771597bf9d9c6c894c54a5172d104c808a1 100644 (file)
@@ -1,3 +1,10 @@
+2010-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/42625
+       * cgraph.c (cgraph_make_node_local): Clear DECL_COMDAT*,
+       TREE_PUBLIC, DECL_WEAK and DECL_EXTERNAL also for same_body
+       aliases.
+
 2010-01-07  Duncan Sands  <baldrick@free.fr>
 
        * Makefile.in (PLUGIN_HEADERS): Add version.h.
index fc7ba1a50bab81367042a936de82e61e678147f7..baaf601c9676bc0338dd74902ac22fad5ac41a53 100644 (file)
@@ -1,5 +1,5 @@
 /* Callgraph handling code.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Jan Hubicka
 
@@ -2197,11 +2197,20 @@ cgraph_make_node_local (struct cgraph_node *node)
   gcc_assert (cgraph_node_can_be_local_p (node));
   if (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))
     {
+      struct cgraph_node *alias;
       DECL_COMDAT (node->decl) = 0;
       DECL_COMDAT_GROUP (node->decl) = 0;
       TREE_PUBLIC (node->decl) = 0;
       DECL_WEAK (node->decl) = 0;
       DECL_EXTERNAL (node->decl) = 0;
+      for (alias = node->same_body; alias; alias = alias->next)
+       {
+         DECL_COMDAT (alias->decl) = 0;
+         DECL_COMDAT_GROUP (alias->decl) = 0;
+         TREE_PUBLIC (alias->decl) = 0;
+         DECL_WEAK (alias->decl) = 0;
+         DECL_EXTERNAL (alias->decl) = 0;
+       }
       node->local.externally_visible = false;
       node->local.local = true;
       gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);
index 459dde397fff58cb85b32ec00ac919d6c5c8d955..d68e6e9fb100242eeaf2edf7415e0c3708e4df1d 100644 (file)
@@ -1,3 +1,10 @@
+2010-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/42625
+       * g++.dg/opt/dtor4.C: New test.
+       * g++.dg/opt/dtor4.h: New.
+       * g++.dg/opt/dtor4-aux.cc: New.
+
 2010-01-07  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/42597
diff --git a/gcc/testsuite/g++.dg/opt/dtor4-aux.cc b/gcc/testsuite/g++.dg/opt/dtor4-aux.cc
new file mode 100644 (file)
index 0000000..e3ca43b
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-do compile }
+// { dg-options "" }
+
+#include "dtor4.h"
+
+S s;
diff --git a/gcc/testsuite/g++.dg/opt/dtor4.C b/gcc/testsuite/g++.dg/opt/dtor4.C
new file mode 100644 (file)
index 0000000..c58fadf
--- /dev/null
@@ -0,0 +1,13 @@
+// PR tree-optimization/42625
+// { dg-do run }
+// { dg-options "-O1 -fipa-sra" }
+// { dg-additional-sources "dtor4-aux.cc" }
+
+#include "dtor4.h"
+
+int
+main ()
+{
+  S s;
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/opt/dtor4.h b/gcc/testsuite/g++.dg/opt/dtor4.h
new file mode 100644 (file)
index 0000000..d3b43be
--- /dev/null
@@ -0,0 +1,8 @@
+#include <cassert>
+
+struct S
+{
+  int a, i;
+  S () : i(1) {}
+  __attribute__((noinline)) ~S () { assert (i == 1); }
+};