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