Debian Codegraph @

gcc/testsuite/c-c++-common/musttail28.c

raw
1 /* { dg-do compile { target { musttail && { c || c++11 } } } } */
2
3 int foo (int, void *);
4 int bar (int, int *);
5 struct S { int a, b, c; };
6 struct T { int d; struct S e; };
7
8 int
9 baz (int x, void *y)
10 {
11 [[gnu::musttail]] return bar (2, &x); /* { dg-warning "address of parameter 'x' passed to 'musttail' call argument" } */
12 }
13
14 int
15 qux (int x, void *y)
16 {
17 __label__ lab;
18 lab:;
19 if (*(int *) y == 1)
20 [[gnu::musttail]] return foo (1, &&lab); /* { dg-warning "address of label passed to 'musttail' call argument" } */
21 if (x == 1)
22 [[gnu::musttail]] return foo (3, 0);
23 else if (x == 2)
24 {
25 {
26 int a = 42;
27 bar (4, &a);
28 }
29 [[gnu::musttail]] return bar (5, 0);
30 }
31 else if (x == 3)
32 {
33 int a = 42;
34 bar (4, &a);
35 [[gnu::musttail]] return bar (6, 0);
36 }
37 else if (x == 4)
38 {
39 int a = 42;
40 [[gnu::musttail]] return bar (7, &a); /* { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" } */
41 }
42 else if (x == 5)
43 {
44 struct T b;
45 [[gnu::musttail]] return bar (8, &b.e.b); /* { dg-warning "address of automatic variable 'b' passed to 'musttail' call argument" } */
46 }
47 else if (x == 6)
48 {
49 struct T b;
50 bar (9, &b.e.a);
51 [[gnu::musttail]] return bar (10, 0);
52 }
53 else if (x == 7)
54 {
55 {
56 struct T b;
57 bar (9, &b.e.a);
58 }
59 [[gnu::musttail]] return bar (11, 0);
60 }
61 else if (x == 8)
62 {
63 {
64 int a = 42;
65 bar (4, &a);
66 }
67 [[gnu::musttail]] return foo (12, 0);
68 }
69 else if (x == 9)
70 {
71 int a = 42;
72 bar (4, &a);
73 [[gnu::musttail]] return foo (13, 0);
74 }
75 else if (x == 10)
76 {
77 int a = 42;
78 [[gnu::musttail]] return foo (14, &a); /* { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" } */
79 }
80 else if (x == 11)
81 {
82 struct T b;
83 [[gnu::musttail]] return foo (15, &b.e.b); /* { dg-warning "address of automatic variable 'b' passed to 'musttail' call argument" } */
84 }
85 else if (x == 12)
86 {
87 struct T b;
88 bar (9, &b.e.a);
89 [[gnu::musttail]] return foo (16, 0);
90 }
91 else if (x == 13)
92 {
93 {
94 struct T b;
95 bar (9, &b.e.a);
96 }
97 [[gnu::musttail]] return foo (17, 0);
98 }
99 return 0;
100 }
101
102 int
103 corge (int x, void *y)
104 {
105 if (*(int *) y == 1)
106 bar (18, &x);
107 [[gnu::musttail]] return bar (2, 0);
108 }