RFA: Testsuite fixes (2/3): struct padding / alignment
diff mbox

Message ID 20110801010113.fph1ot2po0sssswo-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke Aug. 1, 2011, 5:01 a.m. UTC
I am working with a target port that adds alignment and/or padding to certain
structures.  This causes some tests to fail that assume such padding does
not exist.

Fixed by adding a packed attribute to the structures in question.

Regression tested with x86_64-unknown-linux-gnu X sh-elf .
No change there, as there is no such added alignment / padding by default
on that target.  (Although there is the -mpadstruct option; but you'd need
to build appropriate mutilibs to test that.)
2011-07-27  Joern Rennecke <joern.rennecke@embecosm.com>

	* g++.dg/ext/strncpy-chk1.C (struct A): Add packed attribute.

2011-07-21  Joern Rennecke <joern.rennecke@embecosm.com>

	* gcc.dg/builtin-object-size-10.c (drone_source_packet): Make packed.

	* gcc.dg/builtin-stringop-chk-1.c (t): Make packed.

Patch
diff mbox

Index: gcc.dg/builtin-object-size-10.c
===================================================================
--- gcc.dg/builtin-object-size-10.c	(.../GNU/fsf-gcc/trunk/gcc/testsuite)	(revision 2013)
+++ gcc.dg/builtin-object-size-10.c	(.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)	(revision 2013)
@@ -8,7 +8,7 @@ 
 typedef struct {
     char type_str[16];
     char channel_hop;
-} drone_source_packet;
+} __attribute__((packed)) drone_source_packet;
 drone_packet *
 foo(char *x)
 {
Index: gcc.dg/builtin-stringop-chk-1.c
===================================================================
--- gcc.dg/builtin-stringop-chk-1.c	(.../GNU/fsf-gcc/trunk/gcc/testsuite)	(revision 2013)
+++ gcc.dg/builtin-stringop-chk-1.c	(.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)	(revision 2013)
@@ -104,7 +104,7 @@  test2 (const H h)
   S *s[3];
   memset (s, 0, sizeof (S) * 3); /* { dg-warning "will always overflow" "memset" } */
 
-  struct T { char a[8]; char b[4]; char c[10]; } t;
+  struct T { char a[8]; char b[4]; char c[10]; } __attribute__((packed)) t;
   stpcpy (t.c,"Testing..."); /* { dg-warning "will always overflow" "stpcpy" } */
 
   char b1[7];
Index: g++.dg/ext/strncpy-chk1.C
===================================================================
--- g++.dg/ext/strncpy-chk1.C	(.../GNU/fsf-gcc/trunk/gcc/testsuite)	(revision 2013)
+++ g++.dg/ext/strncpy-chk1.C	(.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)	(revision 2013)
@@ -2,7 +2,7 @@ 
 // { dg-do compile }
 // { dg-options "-O2" }
 
-struct A { char x[12], y[35]; };
+struct A { char x[12], y[35]; } __attribute__((packed));
 struct B { char z[50]; };
 
 inline void