gcc/testsuite/gcc.c-torture/execute/931004-6.c
raw| 1 | #include <stdarg.h> |
| 2 | |
| 3 | void abort (void); |
| 4 | void exit (int); |
| 5 | |
| 6 | struct tiny |
| 7 | { |
| 8 | short c; |
| 9 | short d; |
| 10 | }; |
| 11 | |
| 12 | void |
| 13 | f (int n, ...) |
| 14 | { |
| 15 | struct tiny x; |
| 16 | int i; |
| 17 | |
| 18 | va_list ap; |
| 19 | va_start (ap,n); |
| 20 | for (i = 0; i < n; i++) |
| 21 | { |
| 22 | x = va_arg (ap,struct tiny); |
| 23 | if (x.c != i + 10) |
| 24 | abort(); |
| 25 | if (x.d != i + 20) |
| 26 | abort(); |
| 27 | } |
| 28 | { |
| 29 | long x = va_arg (ap, long); |
| 30 | if (x != 123) |
| 31 | abort(); |
| 32 | } |
| 33 | va_end (ap); |
| 34 | } |
| 35 | |
| 36 | int |
| 37 | main (void) |
| 38 | { |
| 39 | struct tiny x[3]; |
| 40 | x[0].c = 10; |
| 41 | x[1].c = 11; |
| 42 | x[2].c = 12; |
| 43 | x[0].d = 20; |
| 44 | x[1].d = 21; |
| 45 | x[2].d = 22; |
| 46 | f (3, x[0], x[1], x[2], (long) 123); |
| 47 | exit(0); |
| 48 | } |
| 49 |