* tree-loop-distribution.c (INCLUDE_ALGORITHM): New header file.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-dom-thread-8.c
blobc456d734fa7589d5d075267db6c2161ae30caccd
1 /* PR 64878 */
2 /* { dg-options "-O2" } */
3 /* { dg-do run } */
5 struct A { int a1; };
6 struct B { char *b1; int b2; int b3; };
7 struct C { char *c1; int c2; struct B *c3; };
8 extern struct A *f1 (char *s);
9 static struct A *f2 (struct C *x);
10 __attribute__ ((noinline, noclone)) int f3 (struct A *x, struct A *z) { asm volatile ("" : : "g" (x), "g" (z) : "memory"); return 0; }
11 __attribute__ ((noinline, noclone)) void f4 (struct A *x, char *y, struct A *z) { asm volatile ("" : : "g" (x), "g" (z), "g" (y) : "memory"); }
12 __attribute__ ((noinline, noclone)) struct B *f5 (void) { static char b[32]; static struct B f3 = { b, 0, 32 }; return &f3; }
13 __attribute__ ((noinline, noclone)) int f6 (struct B *p, char *w, int z) { asm volatile ("" : : "g" (p), "g" (w), "g" (z) : "memory"); return 0; }
14 __attribute__ ((noinline, noclone)) void f7 (struct B *p) { asm volatile ("" : : "g" (p) : "memory"); }
15 __attribute__ ((noinline, noclone)) void f8 (struct B *p) { asm volatile ("" : : "g" (p) : "memory"); }
16 __attribute__ ((noinline, noclone)) void f9 (struct A *x) { asm volatile ("" : : "g" (x) : "memory"); }
17 __attribute__ ((noinline, noclone)) struct A *f10 (void) { static struct A j; asm volatile ("" : : : "memory"); return &j; }
18 __attribute__ ((noinline, noclone)) struct A *f11 (void) { static struct A j; asm volatile ("" : : : "memory"); return &j; }
19 __attribute__ ((noinline, noclone)) struct A *f12 (int b) { static struct A j; asm volatile ("" : : "g" (b) : "memory"); return &j; }
20 __attribute__ ((noinline, noclone)) struct A *f13 (int i) { static struct A j; asm volatile ("" : : "g" (i) : "memory"); return &j; }
21 __attribute__ ((noinline, noclone)) struct A *f14 (double d) { static struct A j; asm volatile ("" : : "g" (&d) : "memory"); return &j; }
22 __attribute__ ((noinline, noclone)) struct A *f15 (char *s) { static struct A j; asm volatile ("" : : "g" (s) : "memory"); return &j; }
23 char *t = "0123456789abcdef";
24 char *u = "0123456789.+-e";
26 __attribute__ ((noinline, noclone)) struct A *
27 f1 (char *s)
29 struct C f;
30 struct A *o;
31 f.c1 = s;
32 f.c2 = 0;
33 f.c3 = f5 ();
34 o = f2 (&f);
35 f8 (f.c3);
36 return o;
39 static struct A *
40 f2 (struct C *x)
42 int a, b, e = 0;
43 struct A *f = 0, *o;
44 char *g = 0;
45 char h = '\0';
46 int i = 0, j = 0;
47 a = 0;
48 b = 1;
49 char c;
52 c = x->c1[x->c2];
53 switch (a)
55 case 0:
56 if (c == ' ')
57 x->c2++;
58 else if (c == '/')
60 a = 4;
61 j = x->c2++;
63 else
64 a = b;
65 break;
66 case 1:
67 switch (c)
69 case '{':
70 a = 0;
71 b = 15;
72 f = f10 ();
73 x->c2++;
74 break;
75 case '[':
76 a = 0;
77 b = 13;
78 f = f11 ();
79 x->c2++;
80 break;
81 case 'N':
82 case 'n':
83 a = 3;
84 j = x->c2++;
85 break;
86 case '"':
87 case '\'':
88 h = c;
89 f7 (x->c3);
90 a = 8;
91 j = ++x->c2;
92 break;
93 case 'T':
94 case 't':
95 case 'F':
96 case 'f':
97 a = 11;
98 j = x->c2++;
99 break;
100 case '0' ... '9':
101 case '-':
102 i = 0;
103 a = 12;
104 j = x->c2++;
105 break;
106 default:
107 e = 1;
108 goto out;
110 break;
111 case 2:
112 goto out;
113 case 3:
114 if (__builtin_strncmp ("null", x->c1 + j, x->c2 - j))
116 e = 2;
117 goto out;
119 if (x->c2 - j == 4)
121 f = 0;
122 b = 2;
123 a = 0;
125 else
126 x->c2++;
127 break;
128 case 4:
129 if (c == '*')
130 a = 5;
131 else if (c == '/')
132 a = 6;
133 else
135 e = 8;
136 goto out;
138 x->c2++;
139 break;
140 case 5:
141 if (c == '*')
142 a = 7;
143 x->c2++;
144 break;
145 case 6:
146 if (c == '\n')
147 a = 0;
148 x->c2++;
149 break;
150 case 7:
151 if (c == '/')
152 a = 0;
153 else
154 a = 5;
155 x->c2++;
156 break;
157 case 8:
158 if (c == h)
160 f6 (x->c3, x->c1 + j, x->c2 - j);
161 f = f15 (x->c3->b1);
162 b = 2;
163 a = 0;
165 else if (c == '\\')
167 b = 8;
168 a = 9;
170 x->c2++;
171 break;
172 case 9:
173 switch (c)
175 case '"':
176 case '\\':
177 f6 (x->c3, x->c1 + j, x->c2 - j - 1);
178 j = x->c2++;
179 a = b;
180 break;
181 case 'b':
182 case 'n':
183 case 'r':
184 case 't':
185 f6 (x->c3, x->c1 + j, x->c2 - j - 1);
186 if (c == 'b')
187 f6 (x->c3, "\b", 1);
188 else if (c == 'n')
189 f6 (x->c3, "\n", 1);
190 else if (c == 'r')
191 f6 (x->c3, "\r", 1);
192 else if (c == 't')
193 f6 (x->c3, "\t", 1);
194 j = ++x->c2;
195 a = b;
196 break;
197 case 'u':
198 f6 (x->c3, x->c1 + j, x->c2 - j - 1);
199 j = ++x->c2;
200 a = 10;
201 break;
202 default:
203 e = 7;
204 goto out;
206 break;
207 case 10:
208 if (__builtin_strchr (t, c))
210 x->c2++;
211 if (x->c2 - j == 4)
213 unsigned char w[3];
214 unsigned int s =
215 (((x->c1[j] <= '9') ? x->c1[j] - '0' : (x->c1[j] & 7) + 9) << 12)
216 + (((x->c1[j + 1] <= '9') ? x->c1[j + 1] - '0' : (x->c1[j + 1] & 7) + 9) << 8)
217 + (((x->c1[j + 2] <= '9') ? x->c1[j + 2] - '0' : (x->c1[j + 2] & 7) + 9) << 4)
218 + ((x->c1[j + 3] <= '9') ? x->c1[j + 3] - '0' : (x->c1[j + 3] & 7) + 9);
219 if (s < 0x80)
221 w[0] = s;
222 f6 (x->c3, (char *) w, 1);
224 else if (s < 0x800)
226 w[0] = 0xc0 | (s >> 6);
227 w[1] = 0x80 | (s & 0x3f);
228 f6 (x->c3, (char *) w, 2);
230 else
232 w[0] = 0x0 | (s >> 12);
233 w[1] = 0x80 | ((s >> 6) & 0x3f);
234 w[2] = 0x80 | (s & 0x3f);
235 f6 (x->c3, (char *) w, 3);
237 j = x->c2;
238 a = b;
241 else
243 e = 7;
244 goto out;
246 break;
247 case 11:
248 if (__builtin_strncmp ("true", x->c1 + j, x->c2 - j) == 0)
250 if (x->c2 - j == 4)
252 f = f12 (1);
253 b = 2;
254 a = 0;
256 else
257 x->c2++;
259 else if (__builtin_strncmp ("false", x->c1 + j, x->c2 - j) == 0)
261 if (x->c2 - j == 5)
263 f = f12 (0);
264 b = 2;
265 a = 0;
267 else
268 x->c2++;
270 else
272 e = 3;
273 goto out;
275 break;
276 case 12:
277 if (!c || !__builtin_strchr (u, c))
279 if (!i)
280 f = f13 (0);
281 else
282 f = f14 (0.0);
283 b = 2;
284 a = 0;
286 else
288 if (c == '.' || c == 'e')
289 i = 1;
290 x->c2++;
292 break;
293 case 13:
294 if (c == ']')
296 x->c2++;
297 b = 2;
298 a = 0;
300 else
302 o = f2 (x);
303 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
304 if (((unsigned long) o > (unsigned long) -4000L))
305 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
306 if (((__UINTPTR_TYPE__) o > (__UINTPTR_TYPE__) -4000U))
307 #endif
309 e = 5;
310 goto out;
312 f3 (f, o);
313 b = 14;
314 a = 0;
316 break;
317 case 14:
318 if (c == ']')
320 x->c2++;
321 b = 2;
322 a = 0;
324 else if (c == ',')
326 x->c2++;
327 b = 13;
328 a = 0;
330 else
332 f9 (f);
333 e = 5;
334 goto out;
336 break;
337 case 15:
338 a = 16;
339 j = x->c2;
340 break;
341 case 16:
342 if (c == '}')
344 x->c2++;
345 b = 2;
346 a = 0;
348 else if (c == '"' || c == '\'')
350 h = c;
351 f7 (x->c3);
352 a = 17;
353 j = ++x->c2;
355 else
357 e = 6;
358 goto out;
360 break;
361 case 17:
362 if (c == h)
364 f6 (x->c3, x->c1 + j, x->c2 - j);
365 g = __builtin_strdup (x->c3->b1);
366 b = 18;
367 a = 0;
369 else if (c == '\\')
371 b = 17;
372 a = 9;
374 x->c2++;
375 break;
376 case 18:
377 if (c == ':')
379 x->c2++;
380 b = 19;
381 a = 0;
383 else
385 e = -6;
386 goto out;
388 break;
389 case 19:
390 o = f2 (x);
391 #if __SIZEOF_POINTER__ == __SIZEOF_LONG__
392 if (((unsigned long) o > (unsigned long) -4000L))
393 #elif __SIZEOF_POINTER__ == __SIZEOF_INT__
394 if (((__UINTPTR_TYPE__) o > (__UINTPTR_TYPE__) -4000U))
395 #endif
397 e = 6;
398 goto out;
400 f4 (f, g, o);
401 __builtin_free (g);
402 g = 0;
403 b = 20;
404 a = 0;
405 break;
406 case 20:
407 if (c == '}')
409 x->c2++;
410 b = 2;
411 a = 0;
413 else if (c == ',')
415 x->c2++;
416 b = 15;
417 a = 0;
419 else
421 e = 6;
422 goto out;
424 break;
427 while (c);
428 if (a != 2 && b != 2)
429 e = 9;
430 out:
431 __builtin_free (g);
432 if (e == 0)
433 return f;
434 f9 (f);
435 return 0;
439 main ()
441 asm volatile ("" : : : "memory");
442 struct A *r = f1 ("{ \"id\": null, \"blahah\": \"foobarbazbar\", \"barbar\": { \"barbarbarba\":"
443 "\"abcdefgh\", \"ijklmnopqr\": \"stuvwxyzabcdefghijklmnopqrstuv\", \"xyzxyz\":"
444 " [ \"1\" ] } }");
445 if (!r)
446 __builtin_abort ();
447 return 0;