This is the mail archive of the gcc-bugs@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]

[Bug target/10937] New: -Wpadded produces warning for every file when target is powerpc


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10937

           Summary: -Wpadded produces warning for every file when target is
                    powerpc
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: taylor@candd.org
                CC: gcc-bugs@gcc.gnu.org
GCC target triplet: powerpc-*-*

[This bugreport is just to make sure the bug doesn't fall through the cracks.
And to have it reported in the list of fixed bugs in the appropriate release.
The bug has already been reported to gcc-bugs and gcc-patches with a patch.]


If you take the simple program:

int main(void)
{
  return (0);
}

and compile it using a cross gcc compiler targeting powerpc-elf-eabi
with -Wpadded, you'll get the warning:

<built-in>:0: warning: padding struct to align `overflow_arg_area'

.

This bug is present in 3.2.3 and on the trunk; I would guess (but
didn't verify) that it's also present in 3.3.

Investigating, the problem is in config/rs6000/rs6000.c, function
rs6000_build_va_list.  It's building a structure (__va_list_tag) that
looks like:

    unsigned char gpr;
    unsigned char fpr;

    ==> 2 bytes of padding <==

    void *overflow_arg_area;
    void *reg_save_area;

Since backwards compatability is an issue and it's not very useful to
warn about padding in this structure that the compiler is generating
on the user's behalf (regardless of whether the user has a variable
argument function or not), I think that the only two real solutions
are to either (1) teach gcc to not complain about padding when it is
dealing with an internally created structure or to (2) add a member
that occupies the 2 bytes of padding.  Here's a patch for the latter
solution (against the trunk)

2003-05-21  David Taylor  <dtaylor@emc.com>

	* config/rs6000/rs6000.c (rs6000_build_va_list): Give the two
	bytes of padding in the __va_list_tag structure a name (reserved)
	so that -Wpadded won't warn on *EVERY* user file.

Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.471
diff -c -r1.471 rs6000.c
*** gcc/config/rs6000/rs6000.c	5 May 2003 19:33:48 -0000	1.471
--- gcc/config/rs6000/rs6000.c	19 May 2003 18:51:15 -0000
***************
*** 3848,3854 ****
  tree
  rs6000_build_va_list ()
  {
!   tree f_gpr, f_fpr, f_ovf, f_sav, record, type_decl;
  
    /* For AIX, prefer 'char *' because that's what the system
       header files like.  */
--- 3848,3854 ----
  tree
  rs6000_build_va_list ()
  {
!   tree f_gpr, f_fpr, f_res, f_ovf, f_sav, record, type_decl;
  
    /* For AIX, prefer 'char *' because that's what the system
       header files like.  */
***************
*** 3862,3867 ****
--- 3862,3869 ----
  		      unsigned_char_type_node);
    f_fpr = build_decl (FIELD_DECL, get_identifier ("fpr"), 
  		      unsigned_char_type_node);
+   f_res = build_decl (FIELD_DECL, get_identifier ("reserved"),
+ 		      short_unsigned_type_node);
    f_ovf = build_decl (FIELD_DECL, get_identifier ("overflow_arg_area"),
  		      ptr_type_node);
    f_sav = build_decl (FIELD_DECL, get_identifier ("reg_save_area"),
***************
*** 3869,3874 ****
--- 3871,3877 ----
  
    DECL_FIELD_CONTEXT (f_gpr) = record;
    DECL_FIELD_CONTEXT (f_fpr) = record;
+   DECL_FIELD_CONTEXT (f_res) = record;
    DECL_FIELD_CONTEXT (f_ovf) = record;
    DECL_FIELD_CONTEXT (f_sav) = record;
  
***************
*** 3876,3882 ****
    TYPE_NAME (record) = type_decl;
    TYPE_FIELDS (record) = f_gpr;
    TREE_CHAIN (f_gpr) = f_fpr;
!   TREE_CHAIN (f_fpr) = f_ovf;
    TREE_CHAIN (f_ovf) = f_sav;
  
    layout_type (record);
--- 3879,3886 ----
    TYPE_NAME (record) = type_decl;
    TYPE_FIELDS (record) = f_gpr;
    TREE_CHAIN (f_gpr) = f_fpr;
!   TREE_CHAIN (f_fpr) = f_res;
!   TREE_CHAIN (f_res) = f_ovf;
    TREE_CHAIN (f_ovf) = f_sav;
  
    layout_type (record);


Built and tested both on powerpc-unknown-linux-gnu native and on
i686-pc-linux-gnu x powerpc-elf-eabi.

Here's a testsuite file -- to hopefully keep -Wpadded
working in the future.

2003-05-21  David Taylor  <dtaylor@emc.com>

	* gcc.dg/Wpadded.c: New file.


Index: gcc/testsuite/gcc.dg/Wpadded.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/Wpadded.c
diff -N gcc/testsuite/gcc.dg/Wpadded.c
*** /dev/null   1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.dg/Wpadded.c      16 May 2003 17:55:40 -0000
***************
*** 0 ****
--- 1,9 ----
+ /* Source: EMC.  */
+ 
+ /* { dg-do compile } */
+ /* { dg-options "-Wpadded" } */
+ 
+ struct foo {
+   char bar;
+   long baz;                   /* { dg-warning "padding struct to align" } */
+ } futz;



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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