c++: Implement for namespace statics CWG 2867 - Order of initialization for structure...
[official-gcc.git] / gcc / testsuite / gcc.dg / gnu23-attrs-1.c
blob67ab48349a11f2b9b90bc08e1ebfe91a68e88162
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" } */
7 void f (void) {};
9 [[gnu::alias("f")]] void g (void); /* { dg-error "only weak" "" { target *-*-darwin* } } */
11 void [[gnu::alias("f")]] h (void); /* { dg-warning "does not apply to types" } */
13 struct [[gnu::packed]] s { int a; char b; };
14 _Static_assert (sizeof (struct s) == (sizeof (int) + sizeof (char)));
16 int
17 f2 (void)
19 [[gnu::deprecated]] int a = 1;
20 return a; /* { dg-warning "deprecated" } */
23 int
24 f3 (void)
26 int a [[gnu::deprecated]] = 1;
27 return a; /* { dg-warning "deprecated" } */
30 struct s2 { [[gnu::deprecated]] int a; int b [[gnu::deprecated]]; } x;
32 int
33 f4 (void)
35 return x.a; /* { dg-warning "deprecated" } */
38 int
39 f5 (void)
41 return x.b; /* { dg-warning "deprecated" } */
44 enum e { E1 [[gnu::deprecated]] };
46 enum e
47 f6 (void)
49 return E1; /* { dg-warning "deprecated" } */
52 int
53 f7 ([[gnu::deprecated]] int y)
55 return y; /* { dg-warning "deprecated" } */
58 union [[gnu::deprecated]] u { int x; };
60 void
61 f8 (void)
63 union u var; /* { dg-warning "deprecated" } */
66 enum [[gnu::deprecated]] edep { E2 };
68 void
69 f9 (void)
71 enum edep var; /* { dg-warning "deprecated" } */