This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH to avoid -Wabi warning for bug which is fixed in the current ABI version


While working on the vector mangling stuff, I tried turning on -Wabi by default and noticed that we were getting a lot of "empty class causes non-compliant layout" warnings, which seemed alarming. After investigating I found that this is only true with -fabi-version=1, so the warning should be controlled by -fabi-version as well.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 9d113113900d95e81a60713140e6285fed4dc140
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 23 21:40:31 2010 -0500

    	* class.c (layout_class_type): Don't give -Wabi warning for a bug
    	in a previous ABI version.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index f7e0a93..1bab07d 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5044,6 +5044,7 @@ layout_class_type (tree t, tree *virtuals_p)
       /* G++ used to use DECL_FIELD_OFFSET as if it were the byte
 	 offset of the field.  */
       if (warn_abi
+	  && !abi_version_at_least (2)
 	  && !tree_int_cst_equal (DECL_FIELD_OFFSET (field),
 				  byte_position (field))
 	  && contains_empty_class_p (TREE_TYPE (field)))
diff --git a/gcc/testsuite/g++.dg/abi/empty6.C b/gcc/testsuite/g++.dg/abi/empty6.C
index f786308..1b14a6d 100644
--- a/gcc/testsuite/g++.dg/abi/empty6.C
+++ b/gcc/testsuite/g++.dg/abi/empty6.C
@@ -1,4 +1,4 @@
-// { dg-options "-Wabi" }
+// { dg-options "-Wabi -fabi-version=1" }
 
 struct A {};
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]