[RFA] Fix csky and c6x build failures
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr70025.c
blob7cf28c452e339282a1c4fe546640257c5b00a258
1 /* PR middle-end/70025 */
2 /* { dg-do run } */
3 /* { dg-additional-options "-mtune=z10" { target s390*-*-* } } */
4 /* { dg-require-effective-target int32plus } */
6 typedef char (*F) (unsigned long, void *);
7 typedef union { struct A { char a1, a2, a3, a4; unsigned long a5; F a6; void *a7; } b; char c[1]; } B;
8 struct C { const char *c1; unsigned long c2; };
9 typedef struct D { unsigned long d1; int d2; const char *d3; unsigned long d4, d5; struct C d6[49]; char d7[8]; } E[1];
11 __attribute__ ((noinline, noclone))
12 void foo (register E p)
14 asm volatile ("" : : "r" (p) : "memory");
17 __attribute__ ((noinline, noclone))
18 void bar (register E p)
20 register unsigned long k = p[0].d1 + 1;
21 register struct C *l = &p[0].d6[p[0].d2];
22 register const char *m = l->c1;
23 p[0].d1 = k;
24 if (*m == '\0')
26 register struct A *f = &((B *) m)->b;
27 register unsigned long n = l->c2;
28 register unsigned long o = n + f->a5;
29 if (k < o)
31 register unsigned long i;
32 register unsigned long q = k + 8;
33 register F a6 = f->a6;
34 register void *a7 = f->a7;
35 if (q > o)
36 q = o;
37 for (i = k; i < q; i++)
38 p[0].d7[i - k] = (*a6) (i - n, a7);
39 p[0].d4 = k;
40 p[0].d3 = p[0].d7;
41 p[0].d5 = q;
42 return;
45 while (p[0].d2 > 0 && l[0].c2 != l[-1].c2)
47 p[0].d2--;
48 l--;
50 if (p[0].d2 == 0)
52 p[0].d2 = 0x55555555;
53 return;
55 p[0].d2--;
56 foo (p);
59 char
60 baz (unsigned long i, void *j)
62 if (j != 0)
63 __builtin_abort ();
64 return (char) i;
67 int
68 main ()
70 struct D p;
71 struct A f;
72 __builtin_memset (&f, 0, sizeof (f));
73 f.a2 = 4;
74 f.a5 = 13;
75 f.a6 = baz;
76 __builtin_memset (&p, 0, sizeof (p));
77 p.d6[0].c1 = (const char *) &f;
78 bar (&p);
79 if (p.d4 != 1 || p.d5 != 9 || p.d3 != p.d7)
80 __builtin_abort ();
81 return 0;
84 /* At -O3 the loop in bar() is vectorized and results in a (possibly
85 unreachable) out-of-bounds store to p.d7[8]:
86 _22(D)->d7[8] = _122;
87 { dg-prune-output "-Wstringop-overflow" } */