RFA:fix PR middle-end/23467

Joern RENNECKE joern.rennecke@st.com
Mon Aug 22 17:54:00 GMT 2005


Richard Henderson wrote:

>On Fri, Aug 19, 2005 at 01:07:44PM +0100, Joern RENNECKE wrote:
>  
>
>>!       /* 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;
>>! 	}
>>    
>>
>
>Is TYPE_PACKED handled later?  I'm thinking of
>
>  int __attribute__((packed, aligned (2))) a;
>  
>
As a variable declaration, this elicits a warning: ‘packed’ attribute 
ignored .
handle_packed_attribute only applies this attribute to types and 
FIELD_DECLs.

If this is the sole field declaration in a struct, like:

struct s {
int __attribute__((packed, aligned (2))) a;
};

having an alignment that is lower than the integer mode with the appropriate
size already had the effect of choosing BLKmode for s, and the code in 
question
is thus not executed.

Likewise for:

struct foo {
struct Foo const *ptr;
} __attribute__((packed));

. Mode and alignment is already set to the appropriate value before 
finalize_type_size
is called, with the mode being BLKmode and thus forstalling further 
mode-dependent
alignment.



More information about the Gcc-patches mailing list