PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / pr41239.c
blob9966b867c3b472777649b910b40d77c8da7a7b2d
1 /* PR rtl-optimization/41239 */
3 struct S
5 short nargs;
6 unsigned long arg[2];
7 };
9 extern void abort (void);
10 extern void exit (int);
11 extern char fn1 (int, const char *, int, const char *, const char *);
12 extern void fn2 (int, ...);
13 extern int fn3 (int);
14 extern int fn4 (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
16 unsigned long
17 test (struct S *x)
19 signed int arg1 = x->arg[0];
20 long int arg2 = x->arg[1];
22 if (arg2 == 0)
23 (fn1 (20, "foo", 924, __func__, ((void *) 0))
24 ? (fn2 (fn3 (0x2040082), fn4 ("division by zero")))
25 : (void) 0);
27 return (long int) arg1 / arg2;
30 int
31 main (void)
33 struct S s = { 2, { 5, 0 } };
34 test (&s);
35 abort ();
38 __attribute__((noinline)) char
39 fn1 (int x, const char *y, int z, const char *w, const char *v)
41 asm volatile ("" : : "r" (w), "r" (v) : "memory");
42 asm volatile ("" : "+r" (x) : "r" (y), "r" (z) : "memory");
43 return x;
46 __attribute__((noinline)) int
47 fn3 (int x)
49 asm volatile ("" : "+r" (x) : : "memory");
50 return x;
53 __attribute__((noinline)) int
54 fn4 (const char *x, ...)
56 asm volatile ("" : "+r" (x) : : "memory");
57 return *x;
60 __attribute__((noinline)) void
61 fn2 (int x, ...)
63 asm volatile ("" : "+r" (x) : : "memory");
64 if (x)
65 /* Could be a longjmp or throw too. */
66 exit (0);