]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-attr-deprecated-1.c
CommitLineData
2cc94aa8
JM
1/* Test C2x deprecated attribute: valid uses. */
2/* { dg-do compile } */
3/* { dg-options "-std=c2x -pedantic-errors" } */
4
5/* Similar to tests from gnu2x-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
13dep_int dv; /* { dg-warning "deprecated" } */
14
15void
16g (void)
17{
18 f1 (); /* { dg-warning "deprecated" } */
19}
20
21int
22f2 (void)
23{
24 [[deprecated ("for this reason")]] int a = 1;
25 return a; /* { dg-warning "for this reason" } */
26}
27
28int
29f3 (void)
30{
31 int a [[__deprecated__]] = 1;
32 return a; /* { dg-warning "deprecated" } */
33}
34
35struct s2 { [[__deprecated__("some other message")]] int a; int b [[deprecated]]; } x;
36
37int
38f4 (void)
39{
40 return x.a; /* { dg-warning "some other message" } */
41}
42
43int
44f5 (void)
45{
46 return x.b; /* { dg-warning "deprecated" } */
47}
48
49enum e { E1 [[deprecated("third message")]] };
50
51enum e
52f6 (void)
53{
54 return E1; /* { dg-warning "third message" } */
55}
56
57int
58f7 ([[deprecated]] int y)
59{
60 return y; /* { dg-warning "deprecated" } */
61}
62
63union [[__deprecated__]] u { int x; };
64
65void
66f8 (void)
67{
68 union u var; /* { dg-warning "deprecated" } */
69}
70
71enum [[deprecated("edep reason")]] edep { E2 };
72
73void
74f9 (void)
75{
76 enum edep var; /* { dg-warning "edep reason" } */
77}
78
79union u2 { [[__deprecated__]] int a; int b [[deprecated]]; } y;
80
81int
82f10 (void)
83{
84 return y.a; /* { dg-warning "deprecated" } */
85}
86
87int
88f11 (void)
89{
90 return y.b; /* { dg-warning "deprecated" } */
91}
092508a0
JM
92
93struct [[deprecated]] s { int x; };
94
95void
96f12 (void)
97{
98 struct s var; /* { dg-warning "deprecated" } */
99}