OSDN Git Service

2004-11-12 Mark Mitchell <mark@codesourcery.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / 20030826-2.c
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fomit-frame-pointer" } */
3 /* { dg-options "-O2 -fomit-frame-pointer -march=i386" { target i?86-*-* } } */
4 /* { dg-forbid-option "-m64" { target i?86-*-* } } */
5
6 extern void abort (void);
7 extern void exit (int);
8
9 struct S
10 {
11   int *a;
12   unsigned char *b, c;
13 };
14
15 int u, v, w;
16
17 void
18 foo (unsigned short x)
19 {
20   u += x;
21 }
22
23 int
24 bar (struct S **x, int *y)
25 {
26   w += *y;
27   *y = w + 25;
28   return 0;
29 }
30
31 int
32 baz (struct S **x)
33 {
34   struct S *y = *x;
35   unsigned char *a = y->b;
36
37   foo (*a);
38
39   if (__builtin_expect (y->c != 0 || y->a == &v, 0))
40     return 1;
41
42   if (__builtin_expect (*a == 1, 0))
43     {
44       int a, b = bar (x, &a);
45
46       if (a)
47         return b;
48     }
49
50   return 0;
51 }
52
53 int
54 main (void)
55 {
56   struct S a, *b = &a;
57   unsigned char c;
58
59   __builtin_memset (b, 0, sizeof (a));
60   a.a = &v;
61   a.b = &c;
62   if (baz (&b) != 1)
63     abort ();
64   exit (0);
65 }