| 1 |
/* Test C23 deprecated attribute: valid uses. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
/* Similar to tests from gnu23-attrs-1.c, but using the standard |
| 6 |
attribute instead of gnu::deprecated, and sometimes using |
| 7 |
__deprecated__ or a string-literal argument. */ |
| 8 |
|
| 9 |
[[deprecated]] void f1 (void); |
| 10 |
|
| 11 |
[[deprecated]] typedef int dep_int; |
| 12 |
|
| 13 |
dep_int dv; /* { dg-warning "deprecated" } */ |
| 14 |
|
| 15 |
void |
| 16 |
g (void) |
| 17 |
{ |
| 18 |
f1 (); /* { dg-warning "deprecated" } */ |
| 19 |
} |
| 20 |
|
| 21 |
int |
| 22 |
f2 (void) |
| 23 |
{ |
| 24 |
[[deprecated ("for this reason")]] int a = 1; |
| 25 |
return a; /* { dg-warning "for this reason" } */ |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
f3 (void) |
| 30 |
{ |
| 31 |
int a [[__deprecated__]] = 1; |
| 32 |
return a; /* { dg-warning "deprecated" } */ |
| 33 |
} |
| 34 |
|
| 35 |
struct s2 { [[__deprecated__("some other message")]] int a; int b [[deprecated]]; } x; |
| 36 |
|
| 37 |
int |
| 38 |
f4 (void) |
| 39 |
{ |
| 40 |
return x.a; /* { dg-warning "some other message" } */ |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
f5 (void) |
| 45 |
{ |
| 46 |
return x.b; /* { dg-warning "deprecated" } */ |
| 47 |
} |
| 48 |
|
| 49 |
enum e { E1 [[deprecated("third message")]] }; |
| 50 |
|
| 51 |
enum e |
| 52 |
f6 (void) |
| 53 |
{ |
| 54 |
return E1; /* { dg-warning "third message" } */ |
| 55 |
} |
| 56 |
|
| 57 |
int |
| 58 |
f7 ([[deprecated]] int y) |
| 59 |
{ |
| 60 |
return y; /* { dg-warning "deprecated" } */ |
| 61 |
} |
| 62 |
|
| 63 |
union [[__deprecated__]] u { int x; }; |
| 64 |
|
| 65 |
void |
| 66 |
f8 (void) |
| 67 |
{ |
| 68 |
union u var; /* { dg-warning "deprecated" } */ |
| 69 |
} |
| 70 |
|
| 71 |
enum [[deprecated("edep reason")]] edep { E2 }; |
| 72 |
|
| 73 |
void |
| 74 |
f9 (void) |
| 75 |
{ |
| 76 |
enum edep var; /* { dg-warning "edep reason" } */ |
| 77 |
} |
| 78 |
|
| 79 |
union u2 { [[__deprecated__]] int a; int b [[deprecated]]; } y; |
| 80 |
|
| 81 |
int |
| 82 |
f10 (void) |
| 83 |
{ |
| 84 |
return y.a; /* { dg-warning "deprecated" } */ |
| 85 |
} |
| 86 |
|
| 87 |
int |
| 88 |
f11 (void) |
| 89 |
{ |
| 90 |
return y.b; /* { dg-warning "deprecated" } */ |
| 91 |
} |
| 92 |
|
| 93 |
struct [[deprecated]] s { int x; }; |
| 94 |
|
| 95 |
void |
| 96 |
f12 (void) |
| 97 |
{ |
| 98 |
struct s var; /* { dg-warning "deprecated" } */ |
| 99 |
} |