Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / pr27959.c
blobf1fdda1b2cc832a9b9b992104e8b3aa0b8ac81a6
1 /* PR middle-end/27959 */
2 /* { dg-do run { target { int32plus } } } */
3 /* { dg-options "-O2" } */
4 /* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */
6 extern void abort (void);
8 struct B
10 unsigned int b1, b2, b3;
11 char b4;
14 struct C
16 char c1;
19 struct D
21 char *d1;
22 struct C **d2;
23 unsigned int d3;
26 void
27 __attribute__((noinline))
28 foo (void *x, struct B *y, unsigned int *z)
30 if (x)
31 abort ();
32 if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4)
33 abort ();
34 if (*z != 2)
35 abort ();
38 int
39 __attribute__((noinline))
40 baz (unsigned int *x, unsigned int y)
42 asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
43 return *x + y;
46 inline int bar (unsigned int *x, unsigned int y)
48 if (y < *x)
49 return 0;
50 return baz (x, y);
53 unsigned int *
54 __attribute__((noinline))
55 test (struct D *x, unsigned int *y)
57 struct B b;
58 unsigned int c;
60 bar (y, x->d3);
61 if ((*(x->d2))->c1)
62 c = ((unsigned char) x->d1[0]
63 + ((unsigned char) x->d1[1] << 8)
64 + ((unsigned char) x->d1[2] << 16)
65 + ((short) x->d1[3] << 24));
66 else
68 int d;
69 ((char *) &d)[0] = x->d1[0];
70 ((char *) &d)[1] = x->d1[1];
71 ((char *) &d)[2] = x->d1[2];
72 ((char *) &d)[3] = x->d1[3];
73 c = d;
75 b.b4 = 0;
76 b.b1 = c / 10000L % 10000;
77 b.b2 = c / 100 % 100;
78 b.b3 = c % 100;
79 foo (0, &b, y);
80 return y;
83 int
84 main (void)
86 unsigned int x = 900070503;
87 unsigned int y = 2;
88 struct C c = { 0 }, *cptr = &c;
89 struct D d = { (char *) &x, &cptr, 0 };
90 if (test (&d, &y) != &y)
91 abort ();
92 return 0;