diff mbox

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

Message ID 20110925083619.amfz0d03kwwogo0c-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke Sept. 25, 2011, 12:36 p.m. UTC
This patch has not been reviewed for eight weeks.

----- Forwarded message from amylaar@spamcop.net -----
     Date: Mon, 01 Aug 2011 01:01:13 -0400
     From: Joern Rennecke <amylaar@spamcop.net>
Reply-To: Joern Rennecke <amylaar@spamcop.net>
  Subject: RFA: Testsuite fixes (2/3): struct padding / alignment
       To: gcc-patches@gcc.gnu.org

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.)


----- End forwarded message -----
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.

Comments

Richard Biener Sept. 25, 2011, 5:05 p.m. UTC | #1
On Sun, Sep 25, 2011 at 2:36 PM, Joern Rennecke <amylaar@spamcop.net> wrote:
> This patch has not been reviewed for eight weeks.
>
> ----- Forwarded message from amylaar@spamcop.net -----
>    Date: Mon, 01 Aug 2011 01:01:13 -0400
>    From: Joern Rennecke <amylaar@spamcop.net>
> Reply-To: Joern Rennecke <amylaar@spamcop.net>
>  Subject: RFA: Testsuite fixes (2/3): struct padding / alignment
>      To: gcc-patches@gcc.gnu.org
>
> 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.

I think you should instead dg-skip the tests on your target.  At least ...

> 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.)
>
>
> ----- End forwarded message -----
>
>
> 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.
>
> 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"

... for this case I don't see how padding should affect
builtin-object-size.  If it does,
it looks like a bug in the object-size pass.

Richard.

> } */
>
>   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
>
>
diff mbox

Patch

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