| 1 |
/* Test C23 maybe_unused attribute: valid uses. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors -Wall -Wextra -Wunused" } */ |
| 4 |
|
| 5 |
[[maybe_unused]] static void f1 (void) {} |
| 6 |
|
| 7 |
[[__maybe_unused__]] const int c1 = 1; |
| 8 |
static int c2 [[maybe_unused]] = 2; |
| 9 |
|
| 10 |
int |
| 11 |
g ([[maybe_unused]] int x, int y) |
| 12 |
{ |
| 13 |
[[maybe_unused]] typedef float F; |
| 14 |
[[maybe_unused]] int a; |
| 15 |
int b [[__maybe_unused__]]; |
| 16 |
int c [[maybe_unused]]; |
| 17 |
[[__maybe_unused__]] label1: |
| 18 |
c = y; |
| 19 |
[[maybe_unused]] label2: |
| 20 |
return y; |
| 21 |
} |
| 22 |
|
| 23 |
struct [[maybe_unused]] s { double d; }; |
| 24 |
|
| 25 |
struct s2 { [[__maybe_unused__]] int a; int b [[maybe_unused]]; } x; |
| 26 |
|
| 27 |
enum e { E1 [[maybe_unused]] }; |
| 28 |
|
| 29 |
union [[maybe_unused]] u { int x; }; |
| 30 |
|
| 31 |
enum [[maybe_unused]] eu { E2 }; |
| 32 |
|
| 33 |
union u2 { [[maybe_unused]] int a; int b [[maybe_unused]]; } y; |
| 34 |
|
| 35 |
void |
| 36 |
g2 (int x) |
| 37 |
{ |
| 38 |
switch (x) |
| 39 |
{ |
| 40 |
[[maybe_unused]] case 1: ; |
| 41 |
[[__maybe_unused__]] case 2: ; |
| 42 |
[[maybe_unused]] default: ; |
| 43 |
} |
| 44 |
} |