| 1 |
/* { dg-skip-if "requires io" { freestanding } } */ |
| 2 |
/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */ |
| 3 |
|
| 4 |
#ifndef test |
| 5 |
#include <stdio.h> |
| 6 |
#include <stdlib.h> |
| 7 |
#include <stdarg.h> |
| 8 |
|
| 9 |
void |
| 10 |
inner (int x, ...) |
| 11 |
{ |
| 12 |
va_list ap, ap2; |
| 13 |
va_start (ap, x); |
| 14 |
va_start (ap2, x); |
| 15 |
|
| 16 |
switch (x) |
| 17 |
{ |
| 18 |
#define test(n, ret, fmt, args) \ |
| 19 |
case n: \ |
| 20 |
vprintf (fmt, ap); \ |
| 21 |
if (vprintf (fmt, ap2) != ret) \ |
| 22 |
abort (); \ |
| 23 |
break; |
| 24 |
#include "vprintf-1.c" |
| 25 |
#undef test |
| 26 |
default: |
| 27 |
abort (); |
| 28 |
} |
| 29 |
|
| 30 |
va_end (ap); |
| 31 |
va_end (ap2); |
| 32 |
} |
| 33 |
|
| 34 |
int |
| 35 |
main (void) |
| 36 |
{ |
| 37 |
#define test(n, ret, fmt, args) \ |
| 38 |
inner args; |
| 39 |
#include "vprintf-1.c" |
| 40 |
#undef test |
| 41 |
return 0; |
| 42 |
} |
| 43 |
|
| 44 |
#else |
| 45 |
test (0, 5, "hello", (0)); |
| 46 |
test (1, 6, "hello\n", (1)); |
| 47 |
test (2, 1, "a", (2)); |
| 48 |
test (3, 0, "", (3)); |
| 49 |
test (4, 5, "%s", (4, "hello")); |
| 50 |
test (5, 6, "%s", (5, "hello\n")); |
| 51 |
test (6, 1, "%s", (6, "a")); |
| 52 |
test (7, 0, "%s", (7, "")); |
| 53 |
test (8, 1, "%c", (8, 'x')); |
| 54 |
test (9, 7, "%s\n", (9, "hello\n")); |
| 55 |
test (10, 2, "%d\n", (10, 0)); |
| 56 |
#endif |