PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / pr20601-1.c
blob6eab1ef1ea76d580b98e89a3e462a062e61adbf3
1 /* PR tree-optimization/20601 */
2 /* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "-O1" } { "" } } */
3 extern void abort (void);
4 extern void exit (int);
6 struct T
8 char *t1;
9 char t2[4096];
10 char **t3;
13 int a[5];
14 int b;
15 char **c;
16 int d;
17 char **e;
18 struct T t;
19 char *f[16];
20 char *g[] = { "a", "-u", "b", "c" };
22 __attribute__ ((__noreturn__)) void
23 foo (void)
25 while (1);
28 __attribute__ ((noinline)) char *
29 bar (char *x, unsigned int y)
31 return 0;
34 static inline char *
35 baz (char *x, unsigned int y)
37 if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2))
38 foo ();
39 return bar (x, y);
42 static inline int
43 setup1 (int x)
45 char *p;
46 int rval;
48 if (!baz (t.t2, sizeof (t.t2)))
49 baz (t.t2, sizeof (t.t2));
51 if (x & 0x200)
53 char **h, **i = e;
55 ++d;
56 e = f;
57 if (t.t1 && *t.t1)
58 e[0] = t.t1;
59 else
60 abort ();
62 for (h = e + 1; (*h = *i); ++i, ++h)
65 return 1;
68 static inline int
69 setup2 (void)
71 int j = 1;
73 e = c + 1;
74 d = b - 1;
75 while (d > 0 && e[0][0] == '-')
77 if (e[0][1] != '\0' && e[0][2] != '\0')
78 abort ();
80 switch (e[0][1])
82 case 'u':
83 if (!e[1])
84 abort ();
86 t.t3 = &e[1];
87 d--;
88 e++;
89 break;
90 case 'P':
91 j |= 0x1000;
92 break;
93 case '-':
94 d--;
95 e++;
96 if (j == 1)
97 j |= 0x600;
98 return j;
100 d--;
101 e++;
104 if (d > 0 && !(j & 1))
105 abort ();
107 return j;
111 main (void)
113 int x;
114 c = g;
115 b = 4;
116 x = setup2 ();
117 t.t1 = "/bin/sh";
118 setup1 (x);
119 /* PRE shouldn't transform x into the constant 0x601 here, it's not legal. */
120 if ((x & 0x400) && !a[4])
121 abort ();
122 exit (0);