| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-std=gnu17" { target c } } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
|
| 6 |
void |
| 7 |
err (int a) |
| 8 |
{ |
| 9 |
va_list vp; |
| 10 |
va_start (vp, a); // { dg-error "used in function with fixed arguments" } |
| 11 |
} |
| 12 |
|
| 13 |
#pragma GCC diagnostic push |
| 14 |
#pragma GCC diagnostic ignored "-Wvarargs" |
| 15 |
|
| 16 |
void |
| 17 |
foo0 (int a, int b, ...) |
| 18 |
{ |
| 19 |
va_list vp; |
| 20 |
/* 'a' is not the last argument of the enclosing function, but |
| 21 |
don't warn because we are ignoring -Wvarargs. */ |
| 22 |
va_start (vp, a); |
| 23 |
va_end (vp); |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
foo1 (int a, register int b, ...) // { dg-warning "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } |
| 28 |
{ |
| 29 |
va_list vp; |
| 30 |
/* 'b' is declared with register storage, but don't warn |
| 31 |
because we are ignoring -Wvarargs. */ |
| 32 |
va_start (vp, b); |
| 33 |
va_end (vp); |
| 34 |
} |
| 35 |
|
| 36 |
#pragma GCC diagnostic pop |
| 37 |
|
| 38 |
void |
| 39 |
foo2 (int a, int b, ...) |
| 40 |
{ |
| 41 |
va_list vp; |
| 42 |
/* 'a' is not the last argument of the enclosing function, so |
| 43 |
warn. */ |
| 44 |
va_start (vp, a); /* { dg-warning "second parameter" } */ |
| 45 |
va_end (vp); |
| 46 |
} |
| 47 |
|
| 48 |
void |
| 49 |
foo3 (int a, register int b, ...) // { dg-warning "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } |
| 50 |
{ |
| 51 |
va_list vp; |
| 52 |
/* 'b' is declared with register storage, so warn. */ |
| 53 |
va_start (vp, b); /* { dg-warning "undefined behavior" } */ |
| 54 |
va_end (vp); |
| 55 |
} |