PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / pr65956.c
blobf5c5eeccbb8d1888633d01460402eb17213df945
1 /* PR target/65956 */
3 struct A { char *a; int b; long long c; };
4 char v[3];
6 __attribute__((noinline, noclone)) void
7 fn1 (char *x, char *y)
9 if (x != &v[1] || y != &v[2])
10 __builtin_abort ();
11 v[1]++;
14 __attribute__((noinline, noclone)) int
15 fn2 (char *x)
17 asm volatile ("" : "+g" (x) : : "memory");
18 return x == &v[0];
21 __attribute__((noinline, noclone)) void
22 fn3 (const char *x)
24 if (x[0] != 0)
25 __builtin_abort ();
28 static struct A
29 foo (const char *x, struct A y, struct A z)
31 struct A r = { 0, 0, 0 };
32 if (y.b && z.b)
34 if (fn2 (y.a) && fn2 (z.a))
35 switch (x[0])
37 case '|':
38 break;
39 default:
40 fn3 (x);
42 fn1 (y.a, z.a);
44 return r;
47 __attribute__((noinline, noclone)) int
48 bar (int x, struct A *y)
50 switch (x)
52 case 219:
53 foo ("+", y[-2], y[0]);
54 case 220:
55 foo ("-", y[-2], y[0]);
59 int
60 main ()
62 struct A a[3] = { { &v[1], 1, 1LL }, { &v[0], 0, 0LL }, { &v[2], 2, 2LL } };
63 bar (220, a + 2);
64 if (v[1] != 1)
65 __builtin_abort ();
66 return 0;