| 1 |
/* Test C23 attribute syntax. Test GNU attributes appertain to |
| 2 |
appropriate constructs. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-require-alias "" } */ |
| 5 |
/* { dg-options "-std=gnu23" } */ |
| 6 |
|
| 7 |
void f (void) {}; |
| 8 |
|
| 9 |
[[gnu::alias("f")]] void g (void); /* { dg-error "only weak" "" { target *-*-darwin* } } */ |
| 10 |
|
| 11 |
void [[gnu::alias("f")]] h (void); /* { dg-warning "does not apply to types" } */ |
| 12 |
|
| 13 |
struct [[gnu::packed]] s { int a; char b; }; |
| 14 |
_Static_assert (sizeof (struct s) == (sizeof (int) + sizeof (char))); |
| 15 |
|
| 16 |
int |
| 17 |
f2 (void) |
| 18 |
{ |
| 19 |
[[gnu::deprecated]] int a = 1; |
| 20 |
return a; /* { dg-warning "deprecated" } */ |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
f3 (void) |
| 25 |
{ |
| 26 |
int a [[gnu::deprecated]] = 1; |
| 27 |
return a; /* { dg-warning "deprecated" } */ |
| 28 |
} |
| 29 |
|
| 30 |
struct s2 { [[gnu::deprecated]] int a; int b [[gnu::deprecated]]; } x; |
| 31 |
|
| 32 |
int |
| 33 |
f4 (void) |
| 34 |
{ |
| 35 |
return x.a; /* { dg-warning "deprecated" } */ |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
f5 (void) |
| 40 |
{ |
| 41 |
return x.b; /* { dg-warning "deprecated" } */ |
| 42 |
} |
| 43 |
|
| 44 |
enum e { E1 [[gnu::deprecated]] }; |
| 45 |
|
| 46 |
enum e |
| 47 |
f6 (void) |
| 48 |
{ |
| 49 |
return E1; /* { dg-warning "deprecated" } */ |
| 50 |
} |
| 51 |
|
| 52 |
int |
| 53 |
f7 ([[gnu::deprecated]] int y) |
| 54 |
{ |
| 55 |
return y; /* { dg-warning "deprecated" } */ |
| 56 |
} |
| 57 |
|
| 58 |
union [[gnu::deprecated]] u { int x; }; |
| 59 |
|
| 60 |
void |
| 61 |
f8 (void) |
| 62 |
{ |
| 63 |
union u var; /* { dg-warning "deprecated" } */ |
| 64 |
} |
| 65 |
|
| 66 |
enum [[gnu::deprecated]] edep { E2 }; |
| 67 |
|
| 68 |
void |
| 69 |
f9 (void) |
| 70 |
{ |
| 71 |
enum edep var; /* { dg-warning "deprecated" } */ |
| 72 |
} |