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]

[PATCH] Do not warn about char __attribute__((packed))


Recently the following warning was introduced, which triggers in
cases where it doesn't make any difference if its packed or not, like

/usr/src/linux/include/asm/mpspec_def.h:
   [...]
74 struct mpc_config_bus
75 {
76        unsigned char mpc_type;
77        unsigned char mpc_busid;
78         unsigned char mpc_bustype[6] __attribute((packed));
79 };

The following patch changes the logic to only warn if we try to
pack things that have type alignment smaller than BITS_PER_UNIT.

Ok for mainline, 4.1?

Thanks,
Richard.


2005-12-15  Richard Guenther  <rguenther@suse.de>

	* c-common.c (handle_packed_attribute): Do not warn
	for char with packed attribute.

Index: c-common.c
===================================================================
*** c-common.c	(revision 108564)
--- c-common.c	(working copy)
*************** handle_packed_attribute (tree *node, tre
*** 4075,4086 ****
      }
    else if (TREE_CODE (*node) == FIELD_DECL)
      {
!       if (TYPE_ALIGN (TREE_TYPE (*node)) <= BITS_PER_UNIT)
  	warning (OPT_Wattributes,
  		 "%qE attribute ignored for field of type %qT",
  		 name, TREE_TYPE (*node));
-       else
- 	DECL_PACKED (*node) = 1;
      }
    /* We can't set DECL_PACKED for a VAR_DECL, because the bit is
       used for DECL_REGISTER.  It wouldn't mean anything anyway.
--- 4075,4086 ----
      }
    else if (TREE_CODE (*node) == FIELD_DECL)
      {
!       if (TYPE_ALIGN (TREE_TYPE (*node)) > BITS_PER_UNIT)
! 	DECL_PACKED (*node) = 1;
!       if (TYPE_ALIGN (TREE_TYPE (*node)) < BITS_PER_UNIT)
  	warning (OPT_Wattributes,
  		 "%qE attribute ignored for field of type %qT",
  		 name, TREE_TYPE (*node));
      }
    /* We can't set DECL_PACKED for a VAR_DECL, because the bit is
       used for DECL_REGISTER.  It wouldn't mean anything anyway.


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