re PR c++/20206 (COMDAT broken for C++ thunks)
authorJakub Jelinek <jakub@redhat.com>
Sun, 27 Feb 2005 17:13:28 +0000 (18:13 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 27 Feb 2005 17:13:28 +0000 (18:13 +0100)
PR c++/20206
* decl.c (cxx_comdat_group): Put thunks for
TARGET_USE_LOCAL_THUNK_ALIAS_P (function) functions into the same
comdat group as the thunk target.

* g++.dg/opt/thunk2.C: New test.
* g++.dg/opt/covariant1.C: New test.

From-SVN: r95619

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/covariant1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/thunk2.C [new file with mode: 0644]

index d11e3215997ff9f0bad1236e1e8732927ccf9a84..36e29ce306f185d0c77a9648b347eedd6929d9d9 100644 (file)
@@ -1,3 +1,10 @@
+2005-02-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/20206
+       * decl.c (cxx_comdat_group): Put thunks for
+       TARGET_USE_LOCAL_THUNK_ALIAS_P (function) functions into the same
+       comdat group as the thunk target.
+
 2005-02-24  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * call.c, class.c, cp-tree.h, decl2.c, error.c, init.c, mangle.c,
index d767125ad10e6d58176cdc8ad732171ed6392f35..072519ca1ed4210b9bb1c5ac10a2bc7635b89ae6 100644 (file)
@@ -11115,7 +11115,22 @@ cxx_comdat_group (tree decl)
   /* For all other DECLs, the COMDAT group is the mangled name of the
      declaration itself.  */
   else
-    name = DECL_ASSEMBLER_NAME (decl);
+    {
+      while (DECL_THUNK_P (decl))
+       {
+         /* If TARGET_USE_LOCAL_THUNK_ALIAS_P, use_thunk puts the thunk
+            into the same section as the target function.  In that case
+            we must return target's name.  */
+         tree target = THUNK_TARGET (decl);
+         if (TARGET_USE_LOCAL_THUNK_ALIAS_P (target)
+             && DECL_SECTION_NAME (target) != NULL
+             && DECL_ONE_ONLY (target))
+           decl = target;
+         else
+           break;
+       }
+      name = DECL_ASSEMBLER_NAME (decl);
+    }
 
   return IDENTIFIER_POINTER (name);
 }
index ef1433f0b83f4975aa08d9853ec6cf58ceb11b6c..aebf34b5f6ef7cc8e6ceba932cd640cfa4d8a30d 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/20206
+       * g++.dg/opt/thunk2.C: New test.
+       * g++.dg/opt/covariant1.C: New test.
+
 2005-02-27  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.dg/e_d_fmt.f90: New test.
diff --git a/gcc/testsuite/g++.dg/opt/covariant1.C b/gcc/testsuite/g++.dg/opt/covariant1.C
new file mode 100644 (file)
index 0000000..e57cf4c
--- /dev/null
@@ -0,0 +1,47 @@
+// PR c++/20206
+// { dg-do run }
+// { dg-options "-O0" }
+
+void
+bar (int x)
+{
+  asm ("" : : "g" (x));
+}
+
+struct S { S () {}; virtual ~S () {}; };
+struct T { virtual T *foo (int) {}; };
+struct V : virtual S, virtual T {};
+struct V v;
+struct U : public S, public T
+{
+  bool a;
+  U () {}
+  virtual ~U () {}
+  virtual V *foo (int x)
+  {
+    switch (x)
+      {
+      case 12:
+       break;
+      case 9:
+       bar (7);
+       break;
+      case 10:
+       bar (12);
+       break;
+      case 4:
+       bar (18);
+       break;
+      case 2:
+       bar (26);
+       break;
+      }
+    return &v;
+  }
+};
+U u;
+
+int
+main ()
+{
+}
diff --git a/gcc/testsuite/g++.dg/opt/thunk2.C b/gcc/testsuite/g++.dg/opt/thunk2.C
new file mode 100644 (file)
index 0000000..52fcd74
--- /dev/null
@@ -0,0 +1,44 @@
+// PR c++/20206
+// { dg-do run }
+// { dg-options "-O0" }
+
+void
+bar (int x)
+{
+  asm ("" : : "g" (x));
+}
+
+struct S { S () {}; virtual ~S () {}; };
+struct T { virtual void foo (int) = 0; };
+struct U : public S, public T
+{
+  bool a;
+  U () {}
+  virtual ~U () {}
+  virtual void foo (int x)
+  {
+    switch (x)
+      {
+      case 12:
+       break;
+      case 9:
+       bar (7);
+       break;
+      case 10:
+       bar (12);
+       break;
+      case 4:
+       bar (18);
+       break;
+      case 2:
+       bar (26);
+       break;
+      }
+  }
+};
+U u;
+
+int
+main ()
+{
+}