PR tree-optimization/83369 - Missing diagnostics during inlining
[official-gcc.git] / gcc / testsuite / gcc.dg / pr27959-2.c
blob65894756b9ecb79490e4d9c4792bc561ccf5c1b5
1 /* PR middle-end/27959 */
2 /* { dg-do run { target { stdint_types } } } */
3 /* { dg-options "-O2" } */
4 /* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */
6 #include <stdint.h>
7 extern void abort (void);
9 struct B
11 unsigned int b1, b2, b3;
12 char b4;
15 struct C
17 char c1;
20 struct D
22 char *d1;
23 struct C **d2;
24 unsigned int d3;
27 void
28 __attribute__((noinline))
29 foo (void *x, struct B *y, unsigned int *z)
31 if (x)
32 abort ();
33 if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4)
34 abort ();
35 if (*z != 2)
36 abort ();
39 int
40 __attribute__((noinline))
41 baz (unsigned int *x, unsigned int y)
43 asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
44 return *x + y;
47 inline int bar (unsigned int *x, unsigned int y)
49 if (y < *x)
50 return 0;
51 return baz (x, y);
54 unsigned int *
55 __attribute__((noinline))
56 test (struct D *x, unsigned int *y)
58 struct B b;
59 uint32_t c;
61 bar (y, x->d3);
62 if ((*(x->d2))->c1)
63 c = ((uint32_t) x->d1[0]
64 + ((uint32_t) x->d1[1] << 8)
65 + ((uint32_t) x->d1[2] << 16)
66 + ((uint32_t) x->d1[3] << 24));
67 else
69 int32_t d;
70 ((char *) &d)[0] = x->d1[0];
71 ((char *) &d)[1] = x->d1[1];
72 ((char *) &d)[2] = x->d1[2];
73 ((char *) &d)[3] = x->d1[3];
74 c = d;
76 b.b4 = 0;
77 b.b1 = c / 10000L % 10000;
78 b.b2 = c / 100 % 100;
79 b.b3 = c % 100;
80 foo (0, &b, y);
81 return y;
84 int
85 main (void)
87 uint32_t x = 900070503;
88 unsigned int y = 2;
89 struct C c = { 0 }, *cptr = &c;
90 struct D d = { (char *) &x, &cptr, 0 };
91 if (test (&d, &y) != &y)
92 abort ();
93 return 0;