class.c (finish_struct_1): Check virtual functions for missing ABI tags.
authorJason Merrill <jason@redhat.com>
Thu, 15 Nov 2012 01:53:37 +0000 (20:53 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 15 Nov 2012 01:53:37 +0000 (20:53 -0500)
* class.c (finish_struct_1): Check virtual functions
for missing ABI tags.

From-SVN: r193525

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/doc/extend.texi
gcc/testsuite/g++.dg/abi/abi-tag4.C [new file with mode: 0644]

index bb5e4bad4a7d6702c3284acf1cd7475fb7031e33..af55e29add394ecad609168fb6b73c9286bc5ff6 100644 (file)
@@ -1,5 +1,8 @@
 2012-11-13  Jason Merrill  <jason@redhat.com>
 
+       * class.c (finish_struct_1): Check virtual functions
+       for missing ABI tags.
+
        PR c++/55275
        * pt.c (maybe_process_partial_specialization): Update
        DECL_SOURCE_LOCATION for new specializations.
index 0665e90f5a0bdba1e3588904a06d095e3aeeae67..cdc02ae7d7aee2a199fb7388bcb9baf1420cf252 100644 (file)
@@ -6275,6 +6275,12 @@ finish_struct_1 (tree t)
        /* Here we know enough to change the type of our virtual
           function table, but we will wait until later this function.  */
        build_primary_vtable (CLASSTYPE_PRIMARY_BINFO (t), t);
+
+      /* If we're warning about ABI tags, check the types of the new
+        virtual functions.  */
+      if (warn_abi_tag)
+       for (tree v = virtuals; v; v = TREE_CHAIN (v))
+         check_abi_tags (t, TREE_VALUE (v));
     }
 
   if (TYPE_CONTAINS_VPTR_P (t))
index 25dd685e0ab637ac893f9c4409e85bd4e39204cf..43b21c6231fd3f451070f1b191d456d98d2978fe 100644 (file)
@@ -15622,7 +15622,7 @@ A redeclaration of a function or class must not add new ABI tags,
 since doing so would change the mangled name.
 
 The @option{-Wabi-tag} flag enables a warning about a class which does
-not have all the ABI tags used by its subobjects; for users with code
+not have all the ABI tags used by its subobjects and virtual functions; for users with code
 that needs to coexist with an earlier ABI, using this option can help
 to find all affected types that need to be tagged.
 
diff --git a/gcc/testsuite/g++.dg/abi/abi-tag4.C b/gcc/testsuite/g++.dg/abi/abi-tag4.C
new file mode 100644 (file)
index 0000000..3f8d7bf
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-options "-Wabi-tag" }
+
+struct __attribute ((abi_tag ("X"))) A { };
+
+struct B                       // { dg-warning "abi tag" }
+{
+  virtual void f(A);           // { dg-message "declared here" }
+};