Merge reload-branch up to revision 101000
[official-gcc.git] / gcc / testsuite / gcc.dg / 20020312-2.c
blob763e167a12b91a06106c6abc8cdeb888bfb05c81
1 /* PR 5878.
3 We ICEd in verify_local_live_at_start because we incorrectly forced
4 the PIC register live between BAR and BAZ. We did this because the
5 definition of PIC_OFFSET_TABLE_REGNUM was incorrectly not INVALID_REGNUM
6 when !flag_pic for most targets. */
8 /* { dg-do run } */
9 /* { dg-options "-O -fno-pic" } */
11 extern void abort (void);
13 #if defined(__alpha__)
14 /* PIC register is $29, but is used even without -fpic. */
15 #elif defined(__arc__)
16 # define PIC_REG "26"
17 #elif defined(__arm__)
18 # define PIC_REG "9"
19 #elif defined(AVR)
20 /* No pic register. */
21 #elif defined(__cris__)
22 # define PIC_REG "0"
23 #elif defined(__fr30__)
24 /* No pic register. */
25 #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__)
26 /* No pic register. */
27 #elif defined(_IBMR2)
28 /* No pic register. */
29 #elif defined(__i386__)
30 # define PIC_REG "ebx"
31 #elif defined(__ia64__)
32 /* PIC register is r1, but is used even without -fpic. */
33 #elif defined(__M32R__)
34 /* No pic register. */
35 #elif defined(__m68k__)
36 # define PIC_REG "a5"
37 #elif defined(__mc68hc1x__)
38 /* No pic register. */
39 #elif defined(__mcore__)
40 /* No pic register. */
41 #elif defined(__mips__)
42 /* PIC register is $28, but is used even without -fpic. */
43 #elif defined(__MMIX__)
44 /* No pic register. */
45 #elif defined(__mn10300__)
46 /* No pic register. */
47 #elif #cpu(ns32k)
48 /* No pic register. */
49 #elif defined(__hppa__)
50 /* PIC register is %r27 or %r19, but is used even without -fpic. */
51 #elif defined(__pdp11__)
52 /* No pic register. */
53 #elif defined(__powerpc__) || defined(__PPC__) || defined(__POWERPC__)
54 # ifdef __MACH__
55 # define PIC_REG "31"
56 # else
57 # define PIC_REG "30"
58 # endif
59 #elif defined(__s390__)
60 # define PIC_REG "12"
61 #elif defined(__sparc__)
62 # define PIC_REG "l7"
63 #elif defined(__v850)
64 /* No pic register. */
65 #elif defined(__vax__)
66 /* No pic register. */
67 #elif defined(__xstormy16__)
68 /* No pic register. */
69 #elif defined(__XTENSA__)
70 /* No pic register. */
71 #elif defined(__sh__)
72 # define PIC_REG "r12"
73 #elif defined(__x86_64__)
74 /* No pic register. */
75 #else
76 # error "Modify the test for your target."
77 #endif
79 #if defined PIC_REG && !defined __PIC__ && !defined __pic__
80 register void *reg __asm__(PIC_REG);
81 #else
82 /* We really need a global register variable set to the PIC register
83 to expose the bug. Oh well, let the test case not fail. */
84 static void *reg;
85 #endif
87 void * __attribute__((noinline))
88 dummy (void *x)
90 return x;
93 void
94 f (void)
96 goto *dummy (&&bar);
97 for (;;)
99 foo:
100 reg = (void *) 1;
101 if (!reg)
102 goto baz;
103 reg = &&foo;
106 bar:
107 baz:
108 reg = 0;
112 main()
114 void *old_reg = reg;
115 reg = (void *) 1;
117 f ();
119 /* Additionally test that the prologue/epilogue properly does *not*
120 save and restore global registers. Not possible when the PIC
121 register is in a register window, of course. On Darwin, you can't
122 call library routines from non-PIC code. */
123 #if !defined (__sparc__) && !defined(__MACH__)
124 if (reg)
125 abort ();
126 #endif
128 reg = old_reg;
129 return 0;