2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / 20011119-1.c
blob5b3c00cd36faccd0471eb284fb52e7aa006354b2
1 /* Test for reload failing to eliminate from argp to sp. */
2 /* { dg-do run { target i?86-*-* } } */
3 /* { dg-options "-O2 -fomit-frame-pointer" } */
5 static int ustrsize (const char *s);
6 static int (*ucwidth) (int c);
7 static int (*ugetxc) (const char **s);
8 static int (*usetc) (char *s, int c);
10 char *ustrzcat(char *dest, int size, const char *src)
12 int pos = ustrsize(dest);
13 int c;
15 size -= pos + ucwidth(0);
17 while ((c = ugetxc(&src)) != 0) {
18 size -= ucwidth(c);
19 if (size < 0)
20 break;
22 pos += usetc(dest+pos, c);
25 usetc(dest+pos, 0);
27 return dest;
30 static int __attribute__((noinline))
31 ustrsize (const char *s)
33 return 0;
36 static int
37 ucwidth_ (int c)
39 return 1;
42 static int
43 ugetxc_ (const char **s)
45 return '\0';
48 static int
49 usetc_ (char *s, int c)
51 return 1;
54 int
55 main()
57 ucwidth = ucwidth_;
58 ugetxc = ugetxc_;
59 usetc = usetc_;
61 /* ??? It is impossible to explicitly modify the hard frame pointer.
62 This will run afoul of code in flow.c that declines to mark regs
63 in eliminate_regs in regs_ever_used. Apparently, we have to wait
64 for reload to decide that it won't need a frame pointer before a
65 variable can be allocated to %ebp.
67 So save, restore, and clobber %ebp by hand. */
69 asm ("pushl %%ebp\n\t"
70 "movl $-1, %%ebp\n\t"
71 "pushl $0\n\t"
72 "pushl $0\n\t"
73 "pushl $0\n\t"
74 "call %P0\n\t"
75 "addl $12, %%esp\n\t"
76 "popl %%ebp"
77 : : "i"(ustrzcat));
79 return 0;