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:fix PR middle-end/23467



2005-08-18  J"orn Rennecke <joern.rennecke@st.com>

gcc:
	PR middle-end/23467
	* stor-layout.c (finalize_type_size): Dont override
	existing alignment with a smaller alignment from the mode.
testsuite:
	PR middle-end/23467
	* gcc.c-torture/execute/pr23467.c: New test.

Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.238
diff -p -r1.238 stor-layout.c
*** stor-layout.c	8 Aug 2005 14:22:27 -0000	1.238
--- stor-layout.c	18 Aug 2005 19:26:25 -0000
*************** finalize_type_size (tree type)
*** 1407,1414 ****
  	      && TREE_CODE (type) != QUAL_UNION_TYPE
  	      && TREE_CODE (type) != ARRAY_TYPE)))
      {
!       TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type));
!       TYPE_USER_ALIGN (type) = 0;
      }
  
    /* Do machine-dependent extra alignment.  */
--- 1408,1422 ----
  	      && TREE_CODE (type) != QUAL_UNION_TYPE
  	      && TREE_CODE (type) != ARRAY_TYPE)))
      {
!       unsigned mode_align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
! 
!       /* Don't override a larger alignment requirement coming from a user
! 	 alignment of one of the fields.  */
!       if (mode_align >= TYPE_ALIGN (type))
! 	{
! 	  TYPE_ALIGN (type) = mode_align;
! 	  TYPE_USER_ALIGN (type) = 0;
! 	}
      }
  
    /* Do machine-dependent extra alignment.  */
*** /dev/null	2004-06-24 19:04:38.000000000 +0100
--- testsuite/gcc.c-torture/execute/pr23467.c	2005-08-18 20:12:26.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ struct s1
+ {
+   int __attribute__ ((aligned (8))) a;
+ };
+ 
+ struct
+ {
+   char c;
+   struct s1 m;
+ } v;
+ 
+ int
+ main (void)
+ {
+   if ((int)&v.m & 7)
+     abort ();
+   exit (0);
+ }

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