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]

[RFA:] PR target/18338: Gate ABI assumptions in gcc.dg/bitfld-4.cand g++.dg/abi/bitfield4.C


These tests assume that a structure with bitfields of the "same size
as their type" has the same layout and alignment as the corresponding
non-bitfield struct, i.e.: that
 struct { char a : 8; int b : 32; }
has the same size and alignment as
 struct { char a; int b; }

which just isn't a univeral truth.  I choose to gate the test on two
conditions that imply generally-truth for the test; that either the
type of the bitfield actually matters for the layout (see earlier patch
introducing that attribute) so that the bitfield-struct "is like the
normal struct" or that the struct is packed by default, so that it "is
like the bitfield-struct".  Various alignment macros also have a say,
but from the lack of earlier adjustments it seems those are less common.

Tested cris-elf (default_packed) mmix-knuth-mmixware (neither) and
host powerpc-linux (pcc_bitfield_type_matters).

Ok to commit?

:ADDPATCH testsuite middle-end:

	PR target/18338
	* gcc.dg/bitfld-4.c, g++.dg/abi/bitfield4.C: Gate on
	pcc_bitfield_type_matters || default_packed.

Index: gcc.dg/bitfld-4.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/bitfld-4.c,v
retrieving revision 1.2
diff -p -u -r1.2 bitfld-4.c
--- gcc.dg/bitfld-4.c	10 Aug 2002 13:11:43 -0000	1.2
+++ gcc.dg/bitfld-4.c	23 Oct 2005 23:03:14 -0000
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { target { pcc_bitfield_type_matters || default_packed } } } */
 /* { dg-options "" } */

 /* Check bitfields and non-bitfields are aligned & sized similarly.
Index: g++.dg/abi/bitfield4.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/bitfield4.C,v
retrieving revision 1.1
diff -p -u -r1.1 bitfield4.C
--- g++.dg/abi/bitfield4.C	8 Aug 2002 22:52:20 -0000	1.1
+++ g++.dg/abi/bitfield4.C	23 Oct 2005 23:03:14 -0000
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { target { pcc_bitfield_type_matters || default_packed } } } */

 /* Check bitfields and non-bitfields are aligned & sized similarly.

brgds, H-P


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