1 /* Test for bitfield alignment in structs and unions. */ 2 /* { dg-do run { target pcc_bitfield_type_matters } } */ 3 /* { dg-options "-O2" } */ 4 5 extern void abort (void); 6 extern void exit (int); 7 8 typedef long la __attribute__((aligned (8))); 9 10 struct A 11 { 12 char a; 13 union UA 14 { 15 char x; 16 la y : 6; 17 } b; 18 char c; 19 } a; 20 21 struct B 22 { 23 char a; 24 union UB 25 { 26 char x; 27 long y : 6 __attribute__((aligned (8))); 28 } b; 29 char c; 30 } b; 31 32 struct C 33 { 34 char a; 35 struct UC 36 { 37 la y : 6; 38 } b; 39 char c; 40 } c; 41 42 struct D 43 { 44 char a; 45 struct UD 46 { 47 long y : 6 __attribute__((aligned (8))); 48 } b; 49 char c; 50 } d; 51 main(void)52int main (void) 53 { 54 if (sizeof (a) != sizeof (b)) 55 abort (); 56 if (sizeof (a) != sizeof (c)) 57 abort (); 58 if (sizeof (a) != sizeof (d)) 59 abort (); 60 if ((&a.c - &a.a) != (&b.c - &b.a)) 61 abort (); 62 if ((&a.c - &a.a) != (&c.c - &c.a)) 63 abort (); 64 if ((&a.c - &a.a) != (&d.c - &d.a)) 65 abort (); 66 exit (0); 67 } 68