xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/gcc.dg/20020219-1.c (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /* PR c/4389
2    This testcase failed because host_integerp (x, 0) was returning
3    1 even for constants bigger than 2^31.  It fails under under hpux
4    without -mdisable-indexing because the pointer x - 1 is used as
5    the base address of an indexed load.  Because the struct A is not
6    actually allocated, x - 1 lies in the text segment and this causes
7    the wrong space register to be selected for the load.  */
8 /* { dg-do run } */
9 /* { dg-options "-O2" } */
10 /* { dg-options "-O2 -mdisable-indexing" { target hppa*-*-hpux* } } */
11 
12 /* Disable the test entirely for 16-bit targets.  */
13 #if __INT_MAX__ > 32767
14 
15 extern void abort (void);
16 extern void exit (int);
17 struct A {
18   int a[10000][10000];
19 };
20 int b[2] = { 213151, 0 };
21 
22 void foo (struct A *x, int y)
23 {
24   if (x->a[9999][9999] != x->a[y][y])
25     abort ();
26   if (x->a[9999][9999] != 213151)
27     abort ();
28 }
29 
30 int main (void)
31 {
32   struct A *x;
33   asm ("" : "=r" (x) : "0" (&b[1]));
34   foo (x - 1, 9999);
35   exit (0);
36 }
37 
38 #else
39 
40 int main () { return 0; }
41 
42 #endif /* __INT_MAX__ */
43