comparison gcc/testsuite/gcc.dg/gnu2x-attrs-1.c @ 145:1830386684a0

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