Debian Codegraph @

gcc/testsuite/c-c++-common/attr-unsequenced-1.c

raw
1 /* Test gnu::unsequenced attribute: valid uses. */
2 /* { dg-do compile { target { c || c++11 } } } */
3 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 /* { dg-additional-options "-std=gnu23" { target c } } */
5 /* { dg-final { scan-tree-dump-times " f1 \\\(\\\);" 1 "optimized" } } */
6 /* { dg-final { scan-tree-dump-times " f2 \\\(\\\);" 1 "optimized" } } */
7 /* { dg-final { scan-tree-dump-times " f12 \\\(\\\);" 1 "optimized" } } */
8 /* { dg-final { scan-tree-dump-times " f13 \\\(\\\);" 1 "optimized" } } */
9 /* { dg-final { scan-tree-dump-times " f3 \\\(42\\\);" 1 "optimized" } } */
10 /* { dg-final { scan-tree-dump-times " f5 \\\(42\\\);" 1 "optimized" } } */
11 /* { dg-final { scan-tree-dump-times " f7 \\\(42\\\);" 1 "optimized" } } */
12 /* { dg-final { scan-tree-dump-times " f8 \\\(42\\\);" 1 "optimized" } } */
13 /* { dg-final { scan-tree-dump-times " f9 \\\(42\\\);" 1 "optimized" } } */
14 /* { dg-final { scan-tree-dump-times " f3 \\\(-42\\\);" 1 "optimized" } } */
15 /* { dg-final { scan-tree-dump-times " f5 \\\(-42\\\);" 1 "optimized" } } */
16 /* { dg-final { scan-tree-dump-times " f7 \\\(-42\\\);" 1 "optimized" } } */
17 /* { dg-final { scan-tree-dump-times " f8 \\\(-42\\\);" 1 "optimized" } } */
18 /* { dg-final { scan-tree-dump-times " f9 \\\(-42\\\);" 1 "optimized" } } */
19 /* { dg-final { scan-tree-dump " f3 \\\(52\\\);" "optimized" } } */
20 /* { dg-final { scan-tree-dump-times " fp1\.\[0-9]*_\[0-9]* \\\(14\\\);" 1 "optimized" } } */
21
22 [[gnu::unsequenced]] int f1 ();
23 [[gnu::unsequenced]] int f2 (), f3 (int);
24 int f4 (int, int *) [[gnu::unsequenced]];
25 int f5 (int) [[gnu::unsequenced]];
26 int f6 (int);
27 int (*fp1) (int) [[gnu::unsequenced]] = f6;
28 typedef int ft1 (int) [[gnu::unsequenced]];
29 typedef int ft2 (int);
30 #ifndef __cplusplus
31 extern __typeof (f6) [[gnu::unsequenced]] f7;
32 extern ft2 [[__gnu__::__unsequenced__]] f8;
33 #else
34 int f7 (int) [[gnu::unsequenced, gnu::unsequenced]];
35 int f8 (int) [[__gnu__::unsequenced, gnu::__unsequenced__]];
36 #endif
37 int f1 ();
38 int f9 (int);
39 int f9 (int) [[__gnu__::__unsequenced__]];
40 extern int x;
41
42 int
43 f10 (int x) [[gnu::unsequenced]]
44 {
45 return x + 42;
46 }
47
48 int
49 f11 (int *x, long long y[1], int z) [[__gnu__::__unsequenced__]]
50 {
51 x[0] = z;
52 x[1] = z + 1;
53 x[2] = z + 2;
54 *y = z + 3;
55 return z + 4 + f10 (-42);
56 }
57
58 int f12 () [[gnu::unsequenced]];
59 int f12 () [[gnu::reproducible]];
60 int f13 () [[gnu::reproducible]];
61 int f13 () [[gnu::unsequenced]];
62
63 int
64 g ()
65 {
66 int a = f1 () + f2 () + f3 (42) + f5 (42) + f7 (42) + f8 (42) + f9 (42) + f12 () + f13 ();
67 int b = f1 () + f2 () + f3 (42) + f5 (42) + f7 (42) + f8 (42) + f9 (42) + f12 () + f13 ();
68 int c = f3 (-42) + f5 (-42) + f7 (-42) + f8 (-42) + f9 (-42);
69 int d = f3 (-42) + f5 (-42) + f7 (-42) + f8 (-42) + f9 (-42);
70 int e = fp1 (14) + fp1 (14);
71 x++;
72 int f = f1 () + f2 () + f3 (42) + f5 (42) + f7 (42) + f8 (42) + f9 (42) + f12 () + f13 ();
73 int g = f1 () + f2 () + f3 (42) + f5 (42) + f7 (42) + f8 (42) + f9 (42) + f12 () + f13 ();
74 int h = f3 (-42) + f5 (-42) + f7 (-42) + f8 (-42) + f9 (-42);
75 int i = f3 (-42) + f5 (-42) + f7 (-42) + f8 (-42) + f9 (-42);
76 int j = fp1 (14) + fp1 (14);
77 return a + b + c + d + e + f + g + h + i + j;
78 }
79
80 int
81 h ()
82 {
83 f3 (52);
84 f3 (52);
85 f3 (52);
86 return 0;
87 }