| 1 |
/* Test C23 attribute syntax. Test GNU attributes appertain to |
| 2 |
appropriate constructs. Attributes on types not being defined at |
| 3 |
the time. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-std=gnu23 -Wformat" } */ |
| 6 |
|
| 7 |
typedef void va_type (const char *, ...); |
| 8 |
typedef va_type [[gnu::format (printf, 1, 2)]] printf_like_1; |
| 9 |
typedef void printf_like_2 (const char *, ...) [[gnu::format (printf, 1, 2)]]; |
| 10 |
typedef __typeof__ (void (const char *, ...) [[gnu::format (printf, 1, 2)]]) |
| 11 |
printf_like_3; |
| 12 |
|
| 13 |
va_type func1; |
| 14 |
printf_like_1 func2; |
| 15 |
printf_like_2 func3; |
| 16 |
printf_like_3 func4; |
| 17 |
va_type [[gnu::format (printf, 1, 2)]] *func5 (void); |
| 18 |
|
| 19 |
void |
| 20 |
func_test (void) |
| 21 |
{ |
| 22 |
func1 ("%s", 1); |
| 23 |
func2 ("%s", 1); /* { dg-warning "expects argument" } */ |
| 24 |
func3 ("%s", 1); /* { dg-warning "expects argument" } */ |
| 25 |
func4 ("%s", 1); /* { dg-warning "expects argument" } */ |
| 26 |
func5 () ("%s", 1); /* { dg-warning "expects argument" } */ |
| 27 |
} |
| 28 |
|
| 29 |
typedef int A[2]; |
| 30 |
|
| 31 |
__typeof__ (int [[gnu::deprecated]]) var1; /* { dg-warning "deprecated" } */ |
| 32 |
__typeof__ (A [[gnu::deprecated]]) var2; /* { dg-warning "deprecated" } */ |
| 33 |
__typeof__ (int [3] [[gnu::deprecated]]) var3; /* { dg-warning "deprecated" } */ |