2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20031201-1.c
blob7c8e0ea290f76273f46182fafb4cd478cb8e4c4f
1 /* Copyright (C) 2003 Free Software Foundation.
2 PR target/13256
3 STRICT_LOW_PART was handled incorrectly in delay slots.
4 Origin: Hans-Peter Nilsson. */
6 typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s1;
7 typedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s2;
8 typedef struct { s1 i12; s2 i16; } io;
9 static int test_length = 2;
10 static io *i;
11 static int m = 1;
12 static int d = 1;
13 static unsigned long test_t0;
14 static unsigned long test_t1;
15 void test(void) __attribute__ ((__noinline__));
16 extern int f1 (void *port) __attribute__ ((__noinline__));
17 extern void f0 (void) __attribute__ ((__noinline__));
18 int
19 f1 (void *port)
21 int fail_count = 0;
22 unsigned long tlen;
23 s1 x0 = {0};
24 s2 x1 = {0};
26 i = port;
27 x0.e0 = x1.e0 = 32;
28 i->i12 = x0;
29 i->i16 = x1;
30 do f0(); while (test_t1);
31 x0.e0 = x1.e0 = 8;
32 i->i12 = x0;
33 i->i16 = x1;
34 test ();
35 if (m)
37 unsigned long e = 1000000000 / 460800 * test_length;
38 tlen = test_t1 - test_t0;
39 if (((tlen-e) & 0x7FFFFFFF) > 1000)
40 f0();
42 if (d)
44 unsigned long e = 1000000000 / 460800 * test_length;
45 tlen = test_t1 - test_t0;
46 if (((tlen - e) & 0x7FFFFFFF) > 1000)
47 f0();
49 return fail_count != 0 ? 1 : 0;
52 int
53 main ()
55 io io0;
56 f1 (&io0);
57 abort ();
60 void
61 test (void)
63 io *iop = i;
64 if (iop->i12.e0 != 8 || iop->i16.e0 != 8)
65 abort ();
66 exit (0);
69 void
70 f0 (void)
72 static int washere = 0;
73 io *iop = i;
74 if (washere++ || iop->i12.e0 != 32 || iop->i16.e0 != 32)
75 abort ();