Fortran: Suppress invalid finalization of artificial variable [PR116388]
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / stdarg-2.c
blob40246f937efe6a99119d0e8ffb631ffa08002e79
1 #include <stdarg.h>
3 extern void abort (void);
5 int foo_arg, bar_arg;
6 long x;
7 double d;
8 va_list gap;
10 void
11 foo (int v, va_list ap)
13 switch (v)
15 case 5:
16 foo_arg = va_arg (ap, int);
17 foo_arg += va_arg (ap, double);
18 foo_arg += va_arg (ap, long long);
19 break;
20 case 8:
21 foo_arg = va_arg (ap, long long);
22 foo_arg += va_arg (ap, double);
23 break;
24 case 11:
25 foo_arg = va_arg (ap, int);
26 foo_arg += va_arg (ap, long double);
27 break;
28 default:
29 abort ();
33 void
34 bar (int v)
36 if (v == 0x4002)
38 if (va_arg (gap, int) != 13 || va_arg (gap, double) != -14.0)
39 abort ();
41 bar_arg = v;
44 void
45 f1 (int i, ...)
47 va_start (gap, i);
48 x = va_arg (gap, long);
49 va_end (gap);
52 void
53 f2 (int i, ...)
55 va_start (gap, i);
56 bar (i);
57 va_end (gap);
60 void
61 f3 (int i, ...)
63 va_list aps[10];
64 va_start (aps[4], i);
65 x = va_arg (aps[4], long);
66 va_end (aps[4]);
69 void
70 f4 (int i, ...)
72 va_list aps[10];
73 va_start (aps[4], i);
74 bar (i);
75 va_end (aps[4]);
78 void
79 f5 (int i, ...)
81 va_list aps[10];
82 va_start (aps[4], i);
83 foo (i, aps[4]);
84 va_end (aps[4]);
87 struct A { int i; va_list g; va_list h[2]; };
89 void
90 f6 (int i, ...)
92 struct A a;
93 va_start (a.g, i);
94 x = va_arg (a.g, long);
95 va_end (a.g);
98 void
99 f7 (int i, ...)
101 struct A a;
102 va_start (a.g, i);
103 bar (i);
104 va_end (a.g);
107 void
108 f8 (int i, ...)
110 struct A a;
111 va_start (a.g, i);
112 foo (i, a.g);
113 va_end (a.g);
116 void
117 f10 (int i, ...)
119 struct A a;
120 va_start (a.h[1], i);
121 x = va_arg (a.h[1], long);
122 va_end (a.h[1]);
125 void
126 f11 (int i, ...)
128 struct A a;
129 va_start (a.h[1], i);
130 bar (i);
131 va_end (a.h[1]);
134 void
135 f12 (int i, ...)
137 struct A a;
138 va_start (a.h[1], i);
139 foo (i, a.h[1]);
140 va_end (a.h[1]);
144 main (void)
146 f1 (1, 79L);
147 if (x != 79L)
148 abort ();
149 f2 (0x4002, 13, -14.0);
150 if (bar_arg != 0x4002)
151 abort ();
152 f3 (3, 2031L);
153 if (x != 2031)
154 abort ();
155 f4 (4, 18);
156 if (bar_arg != 4)
157 abort ();
158 f5 (5, 1, 19.0, 18LL);
159 if (foo_arg != 38)
160 abort ();
161 f6 (6, 18L);
162 if (x != 18L)
163 abort ();
164 f7 (7);
165 if (bar_arg != 7)
166 abort ();
167 f8 (8, 2031LL, 13.0);
168 if (foo_arg != 2044)
169 abort ();
170 f10 (9, 180L);
171 if (x != 180L)
172 abort ();
173 f11 (10);
174 if (bar_arg != 10)
175 abort ();
176 f12 (11, 2030, 12.0L);
177 if (foo_arg != 2042)
178 abort ();
179 return 0;