Add a couple of new test cases for nested function support.

From-SVN: r37504
This commit is contained in:
Nick Clifton 2000-11-16 19:45:23 +00:00 committed by Nick Clifton
parent 68dfd979ac
commit e24fa9dac1
3 changed files with 114 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2000-11-16 Nick Clifton <nickc@redhat.com>
* gcc.c-torture/execute/nestfunc-2.c: New test.
* gcc.c-torture/execute/nestfunc-3.c: New test.
2000-11-11 Bernd Schmidt <bernds@redhat.co.uk>
* gcc.c-torture/compile/20001116-1.c: New test.

View File

@ -0,0 +1,49 @@
extern int foo (int, int, int (*) (int, int, int, int, int, int, int));
int z;
int
main (void)
{
#ifndef NO_TRAMPOLINES
int sum = 0;
int i;
int nested (int a, int b, int c, int d, int e, int f, int g)
{
z = c + d + e + f + g;
if (a > 2 * b)
return a - b;
else
return b - a;
}
for (i = 0; i < 10; ++i)
{
int j;
for (j = 0; j < 10; ++j)
{
int k;
for (k = 0; k < 10; ++k)
sum += foo (i, j > k ? j - k : k - j, nested);
}
}
if (sum != 2300)
abort ();
if (z != 0x1b)
abort ();
#endif
exit (0);
}
int
foo (int a, int b, int (* fp) (int, int, int, int, int, int, int))
{
return fp (a, b, a, b, a, b, a);
}

View File

@ -0,0 +1,60 @@
extern long foo (long, long, long (*) (long, long));
extern long use (long (*) (long, long), long, long);
int
main (void)
{
#ifndef NO_TRAMPOLINES
long sum = 0;
long i;
long nested_0 (long a, long b)
{
if (a > 2 * b)
return a - b;
else
return b - a;
}
long nested_1 (long a, long b)
{
return use (nested_0, b, a) + sum;
}
long nested_2 (long a, long b)
{
return nested_1 (b, a);
}
for (i = 0; i < 10; ++i)
{
long j;
for (j = 0; j < 10; ++j)
{
long k;
for (k = 0; k < 10; ++k)
sum += foo (i, j > k ? j - k : k - j, nested_2);
}
}
if (sum != 0xbecfcbf5)
abort ();
#endif
exit (0);
}
long
use (long (* func)(long, long), long a, long b)
{
return func (b, a);
}
long
foo (long a, long b, long (* func) (long, long))
{
return func (a, b);
}