gcc/testsuite/gcc.c-torture/execute/va-arg-11.c
raw| 1 | /* Test va_arg when the result is ignored and only the pointer increment |
| 2 | side effect is used. */ |
| 3 | #include <stdarg.h> |
| 4 | |
| 5 | void abort (void); |
| 6 | void exit (int); |
| 7 | |
| 8 | static int |
| 9 | foo (int a, ...) |
| 10 | { |
| 11 | va_list va; |
| 12 | int i, res; |
| 13 | |
| 14 | va_start (va, a); |
| 15 | |
| 16 | for (i = 0; i < 4; ++i) |
| 17 | (void) va_arg (va, int); |
| 18 | |
| 19 | res = va_arg (va, int); |
| 20 | |
| 21 | va_end (va); |
| 22 | |
| 23 | return res; |
| 24 | } |
| 25 | |
| 26 | int |
| 27 | main (void) |
| 28 | { |
| 29 | if (foo (5, 4, 3, 2, 1, 0)) |
| 30 | abort (); |
| 31 | exit (0); |
| 32 | } |