re PR target/25908 (vtables with vague linkage is not being marked as vague on darwin)
authorMike Stump <mrs@apple.com>
Thu, 2 Mar 2006 02:20:54 +0000 (02:20 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Thu, 2 Mar 2006 02:20:54 +0000 (02:20 +0000)
PR darwin/25908
* decl2.c (import_export_decl): Fix ABI breakage on darwin.

* g++.dg/abi/key2.C: Add.

From-SVN: r111632

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/key2.C [new file with mode: 0644]

index a1df2bb..c092c39 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-01  Mike Stump  <mrs@apple.com>
+
+       PR darwin/25908
+       * decl2.c (import_export_decl): Fix ABI breakage on darwin.
+
 2006-02-24  Geoffrey Keating  <geoffk@apple.com>
 
        * except.c (expand_start_catch_block): Handle
index 18cdae2..9cc95b6 100644 (file)
@@ -1784,9 +1784,14 @@ import_export_decl (tree decl)
              /* The generic C++ ABI says that class data is always
                 COMDAT, even if there is a key function.  Some
                 variants (e.g., the ARM EABI) says that class data
-                only has COMDAT linkage if the class data might
-                be emitted in more than one translation unit.  */
+                only has COMDAT linkage if the class data might be
+                emitted in more than one translation unit.  When the
+                key method can be inline and is inline, we still have
+                to arrange for comdat even though
+                class_data_always_comdat is false.  */
              if (!CLASSTYPE_KEY_METHOD (class_type)
+                 || (DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (class_type))
+                     && targetm.cxx.key_method_may_be_inline ())
                  || targetm.cxx.class_data_always_comdat ())
                {
                  /* The ABI requires COMDAT linkage.  Normally, we
@@ -1825,7 +1830,10 @@ import_export_decl (tree decl)
              if (CLASSTYPE_INTERFACE_KNOWN (type)
                  && !CLASSTYPE_INTERFACE_ONLY (type))
                {
-                 comdat_p = targetm.cxx.class_data_always_comdat ();
+                 comdat_p = (targetm.cxx.class_data_always_comdat ()
+                             || (CLASSTYPE_KEY_METHOD (type)
+                                 && DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (type))
+                                 && targetm.cxx.key_method_may_be_inline ()));
                  mark_needed (decl);
                  if (!flag_weak)
                    {
index 26c178b..5ccb65c 100644 (file)
@@ -1,3 +1,7 @@
+2006-03-01  Mike Stump  <mrs@apple.com>
+
+       * g++.dg/abi/key2.C: Add.
+
 2006-03-01  Paul Thomas  <pault@gcc.gnu.org>
 
        * gfortran.dg/logical_dot_product.f90: New test. 
diff --git a/gcc/testsuite/g++.dg/abi/key2.C b/gcc/testsuite/g++.dg/abi/key2.C
new file mode 100644 (file)
index 0000000..40cf1d5
--- /dev/null
@@ -0,0 +1,16 @@
+// On Darwin, key methods that are inline result in comdat style things.  */
+// PR darwin/25908
+
+// { dg-do compile { target *-*-darwin* } }
+// { dg-final { scan-assembler ".globl __ZTV1f\\n      .weak_definition __ZTV1f\\n     .section __DATA,__const_coal,coalesced" } }
+// { dg-final { scan-assembler ".globl __ZTS1f\\n      .weak_definition __ZTS1f\\n     .section __TEXT,__const_coal,coalesced" } }
+// { dg-final { scan-assembler ".globl __ZTI1f\\n      .weak_definition __ZTI1f\\n     .section __DATA,__const_coal,coalesced" } }
+
+class f
+{
+  virtual void g();
+  virtual void h();
+} c;
+inline void f::g() {}
+int sub(void)
+{}