OSDN Git Service

PR tree-optimization/52019
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / guality / pr43051-1.c
1 /* PR debug/43051 */
2 /* { dg-do run } */
3 /* { dg-options "-g" } */
4
5 extern void abort (void);
6
7 static void __attribute__ ((noinline))
8 foo (const char *x, long long y, int z)
9 {
10   asm volatile ("" : : "r" (x), "r" ((int) y), "r" (z) : "memory");
11 }
12
13 struct S
14 {
15   struct S *n;
16   int v;
17 };
18
19 struct S a[10];
20
21 struct S * __attribute__ ((noinline))
22 bar (struct S *c, int v, struct S *e)
23 {
24 #ifdef __i386__
25   register int si asm ("esi"), di asm ("edi"), bx
26 # if !defined (__pic__) && !defined (__APPLE__)
27     asm ("ebx")
28 # endif
29     ;
30   asm volatile ("" : "=r" (si), "=r" (di), "=r" (bx));
31 #endif
32   while (c < e)
33     {
34       foo ("c", (__UINTPTR_TYPE__) c, 0);       /* { dg-final { gdb-test 34 "c" "\&a\[0\]" } } */
35       foo ("v", v, 1);                          /* { dg-final { gdb-test 35 "v" "1" } } */
36       foo ("e", (__UINTPTR_TYPE__) e, 2);       /* { dg-final { gdb-test 36 "e" "\&a\[1\]" } } */
37       if (c->v == v)
38         return c;
39       foo ("c", (__UINTPTR_TYPE__) c, 3);       /* { dg-final { gdb-test 39 "c" "\&a\[0\]" } } */
40       foo ("v", v, 4);                          /* { dg-final { gdb-test 40 "v" "1" } } */
41       foo ("e", (__UINTPTR_TYPE__) e, 5);       /* { dg-final { gdb-test 41 "e" "\&a\[1\]" } } */
42       c++;
43     }
44 #ifdef __i386__
45   asm volatile ("" : : "r" (si), "r" (di), "r" (bx));
46 #endif
47   return 0;
48 }
49
50 int
51 main ()
52 {
53   asm volatile ("" : : "r" (&a[0]) : "memory");
54   if (bar (&a[a[0].v], a[0].v + 1, &a[a[0].v + 1]))
55     abort ();
56   return 0;
57 }