stor-layout.c (update_alignment_for_field): Use ADJUST_FIELD_ALIGN when computing the alignment for a zero-width bitfield...
* stor-layout.c (update_alignment_for_field): Use ADJUST_FIELD_ALIGN when computing the alignment for a zero-width bitfield when PCC_BITFIELD_TYPE_MATTERS. From-SVN: r60419
This commit is contained in:
parent
bea096ccbf
commit
d0ff2db506
3 changed files with 32 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
2002-12-22 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* stor-layout.c (update_alignment_for_field): Use
|
||||
ADJUST_FIELD_ALIGN when computing the alignment for a zero-width
|
||||
bitfield when PCC_BITFIELD_TYPE_MATTERS.
|
||||
|
||||
2002-12-22 Kazu Hirata <kazu@cs.umass.edu>
|
||||
|
||||
* genautomata.c: Fix comment typos.
|
||||
|
|
|
@ -722,7 +722,10 @@ update_alignment_for_field (rli, field, known_align)
|
|||
if (! integer_zerop (DECL_SIZE (field)))
|
||||
rli->record_align = MAX (rli->record_align, desired_align);
|
||||
else if (! DECL_PACKED (field))
|
||||
desired_align = TYPE_ALIGN (type);
|
||||
{
|
||||
desired_align = TYPE_ALIGN (type);
|
||||
desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
|
||||
}
|
||||
|
||||
/* A named bit field of declared type `int'
|
||||
forces the entire structure to have `int' alignment. */
|
||||
|
|
22
gcc/testsuite/gcc.dg/i386-bitfield2.c
Normal file
22
gcc/testsuite/gcc.dg/i386-bitfield2.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Test for bitfield alignment in structs on IA-32
|
||||
// { dg-do run { target i?86-*-* } }
|
||||
// { dg-options "-O2" }
|
||||
// { dg-options "-mno-align-double -mno-ms-bitfields" { target *-*-interix* } }
|
||||
|
||||
extern void abort (void);
|
||||
extern void exit (int);
|
||||
|
||||
struct X {
|
||||
char a;
|
||||
long long : 0;
|
||||
char b;
|
||||
} x;
|
||||
|
||||
int main () {
|
||||
if (&x.b - &x.a != 4)
|
||||
abort ();
|
||||
if (sizeof (x) != 5)
|
||||
abort ();
|
||||
|
||||
exit (0);
|
||||
}
|
Loading…
Add table
Reference in a new issue