gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c
raw| 1 | /* { dg-additional-options "-std=gnu89" } */ |
| 2 | |
| 3 | typedef struct |
| 4 | { |
| 5 | short i __attribute__ ((aligned (2),packed)); |
| 6 | int f[2] __attribute__ ((aligned (2),packed)); |
| 7 | } A; |
| 8 | |
| 9 | f (ap) |
| 10 | A *ap; |
| 11 | { |
| 12 | short i, j = 1; |
| 13 | |
| 14 | i = ap->f[1]; |
| 15 | i += ap->f[j]; |
| 16 | for (j = 0; j < 2; j++) |
| 17 | i += ap->f[j]; |
| 18 | |
| 19 | return i; |
| 20 | } |
| 21 | |
| 22 | main () |
| 23 | { |
| 24 | A a; |
| 25 | a.f[0] = 100; |
| 26 | a.f[1] = 13; |
| 27 | if (f (&a) != 139) |
| 28 | abort (); |
| 29 | exit (0); |
| 30 | } |