1 |
298 |
jeremybenn |
/* First dg-final line after each function is for architectures that use
|
2 |
|
|
a struct {...} va_list[1] with separate GPR and FPR counters in the
|
3 |
|
|
structure. Second dg-final line is for architectures that use void *
|
4 |
|
|
or char * va_list. */
|
5 |
|
|
/* { dg-do compile } */
|
6 |
|
|
/* { dg-options "-O2 -fdump-tree-stdarg" } */
|
7 |
|
|
|
8 |
|
|
#include <stdarg.h>
|
9 |
|
|
|
10 |
|
|
extern void foo (int, va_list);
|
11 |
|
|
extern void bar (int);
|
12 |
|
|
long x;
|
13 |
|
|
va_list gap;
|
14 |
|
|
|
15 |
|
|
/* If va_list is not local variable, it escapes the function. */
|
16 |
|
|
void
|
17 |
|
|
f1 (int i, ...)
|
18 |
|
|
{
|
19 |
|
|
va_start (gap, i);
|
20 |
|
|
x = va_arg (gap, long);
|
21 |
|
|
va_end (gap);
|
22 |
|
|
}
|
23 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
24 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
25 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
26 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
27 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
28 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
29 |
|
|
/* { dg-final { scan-tree-dump "f1: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
30 |
|
|
|
31 |
|
|
void
|
32 |
|
|
f2 (int i, ...)
|
33 |
|
|
{
|
34 |
|
|
va_start (gap, i);
|
35 |
|
|
bar (i);
|
36 |
|
|
va_end (gap);
|
37 |
|
|
}
|
38 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
39 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
40 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
41 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
42 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
43 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
44 |
|
|
/* { dg-final { scan-tree-dump "f2: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
45 |
|
|
|
46 |
|
|
/* tree-stdarg.c only handles va_list variables, not arrays of them or
|
47 |
|
|
va_list fields embedded in structures. */
|
48 |
|
|
void
|
49 |
|
|
f3 (int i, ...)
|
50 |
|
|
{
|
51 |
|
|
va_list aps[10];
|
52 |
|
|
va_start (aps[4], i);
|
53 |
|
|
x = va_arg (aps[4], long);
|
54 |
|
|
va_end (aps[4]);
|
55 |
|
|
}
|
56 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
57 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
58 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
59 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
60 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
61 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
62 |
|
|
/* { dg-final { scan-tree-dump "f3: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
63 |
|
|
|
64 |
|
|
void
|
65 |
|
|
f4 (int i, ...)
|
66 |
|
|
{
|
67 |
|
|
va_list aps[10];
|
68 |
|
|
va_start (aps[4], i);
|
69 |
|
|
bar (i);
|
70 |
|
|
va_end (aps[4]);
|
71 |
|
|
}
|
72 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
73 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
74 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
75 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
76 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
77 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
78 |
|
|
/* { dg-final { scan-tree-dump "f4: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
79 |
|
|
|
80 |
|
|
void
|
81 |
|
|
f5 (int i, ...)
|
82 |
|
|
{
|
83 |
|
|
va_list aps[10];
|
84 |
|
|
va_start (aps[4], i);
|
85 |
|
|
foo (i, aps[4]);
|
86 |
|
|
va_end (aps[4]);
|
87 |
|
|
}
|
88 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
89 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
90 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
91 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
92 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
93 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
94 |
|
|
/* { dg-final { scan-tree-dump "f5: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
95 |
|
|
|
96 |
|
|
struct A { int i; va_list g; va_list h[2]; };
|
97 |
|
|
|
98 |
|
|
void
|
99 |
|
|
f6 (int i, ...)
|
100 |
|
|
{
|
101 |
|
|
struct A a;
|
102 |
|
|
va_start (a.g, i);
|
103 |
|
|
x = va_arg (a.g, long);
|
104 |
|
|
va_end (a.g);
|
105 |
|
|
}
|
106 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
107 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
108 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
109 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
110 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
111 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
112 |
|
|
/* { dg-final { scan-tree-dump "f6: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
113 |
|
|
|
114 |
|
|
void
|
115 |
|
|
f7 (int i, ...)
|
116 |
|
|
{
|
117 |
|
|
struct A a;
|
118 |
|
|
va_start (a.g, i);
|
119 |
|
|
bar (i);
|
120 |
|
|
va_end (a.g);
|
121 |
|
|
}
|
122 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
123 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
124 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
125 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
126 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
127 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
128 |
|
|
/* { dg-final { scan-tree-dump "f7: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
129 |
|
|
|
130 |
|
|
void
|
131 |
|
|
f8 (int i, ...)
|
132 |
|
|
{
|
133 |
|
|
struct A a;
|
134 |
|
|
va_start (a.g, i);
|
135 |
|
|
foo (i, a.g);
|
136 |
|
|
va_end (a.g);
|
137 |
|
|
}
|
138 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
139 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
140 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
141 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
142 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
143 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
144 |
|
|
/* { dg-final { scan-tree-dump "f8: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
145 |
|
|
|
146 |
|
|
void
|
147 |
|
|
f10 (int i, ...)
|
148 |
|
|
{
|
149 |
|
|
struct A a;
|
150 |
|
|
va_start (a.h[1], i);
|
151 |
|
|
x = va_arg (a.h[1], long);
|
152 |
|
|
va_end (a.h[1]);
|
153 |
|
|
}
|
154 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
155 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
156 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
157 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
158 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
159 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
160 |
|
|
/* { dg-final { scan-tree-dump "f10: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
161 |
|
|
|
162 |
|
|
void
|
163 |
|
|
f11 (int i, ...)
|
164 |
|
|
{
|
165 |
|
|
struct A a;
|
166 |
|
|
va_start (a.h[1], i);
|
167 |
|
|
bar (i);
|
168 |
|
|
va_end (a.h[1]);
|
169 |
|
|
}
|
170 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
171 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
172 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
173 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
174 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
175 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
176 |
|
|
/* { dg-final { scan-tree-dump "f11: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
177 |
|
|
|
178 |
|
|
void
|
179 |
|
|
f12 (int i, ...)
|
180 |
|
|
{
|
181 |
|
|
struct A a;
|
182 |
|
|
va_start (a.h[1], i);
|
183 |
|
|
foo (i, a.h[1]);
|
184 |
|
|
va_end (a.h[1]);
|
185 |
|
|
}
|
186 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
|
187 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
|
188 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target alpha*-*-linux* } } } */
|
189 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units and all FPR units" "stdarg" { target s390*-*-linux* } } } */
|
190 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } } */
|
191 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units" "stdarg" { target ia64-*-* } } } */
|
192 |
|
|
/* { dg-final { scan-tree-dump "f12: va_list escapes 1, needs to save all GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
|
193 |
|
|
/* { dg-final { cleanup-tree-dump "stdarg" } } */
|