| 1 |
/* Test C23 maybe_unused attribute: invalid contexts. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
/* This attribute is not valid in most cases on types other than their |
| 6 |
definitions, or on statements, or as an attribute-declaration. */ |
| 7 |
|
| 8 |
[[maybe_unused]]; /* { dg-error "ignored" } */ |
| 9 |
|
| 10 |
int [[maybe_unused]] var; /* { dg-error "ignored" } */ |
| 11 |
|
| 12 |
int array_with_dep_type[2] [[maybe_unused]]; /* { dg-error "ignored" } */ |
| 13 |
|
| 14 |
void fn_with_dep_type () [[maybe_unused]]; /* { dg-error "ignored" } */ |
| 15 |
|
| 16 |
int z = sizeof (int [[__maybe_unused__]]); /* { dg-error "ignored" } */ |
| 17 |
|
| 18 |
void |
| 19 |
f (void) |
| 20 |
{ |
| 21 |
int a; |
| 22 |
[[maybe_unused]]; /* { dg-error "ignored" } */ |
| 23 |
[[maybe_unused]] a = 1; /* { dg-error "ignored" } */ |
| 24 |
} |