From 07b1b0304a88aa46e39208747b5438ffef317617 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Thu, 28 Jan 1999 16:05:21 +0000 Subject: [PATCH] add new test From-SVN: r24897 --- gcc/testsuite/gcc.c-torture/ChangeLog | 4 ++ .../gcc.c-torture/execute/990128-1.c | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/990128-1.c diff --git a/gcc/testsuite/gcc.c-torture/ChangeLog b/gcc/testsuite/gcc.c-torture/ChangeLog index abecc17003f..3f160c5c416 100644 --- a/gcc/testsuite/gcc.c-torture/ChangeLog +++ b/gcc/testsuite/gcc.c-torture/ChangeLog @@ -1,3 +1,7 @@ +1999-01-28 Michael Meissner + + * execute/990128-1.c: New test. + 1999-01-27 Michael Meissner * execute/990127-{1,2}.c: New tests. diff --git a/gcc/testsuite/gcc.c-torture/execute/990128-1.c b/gcc/testsuite/gcc.c-torture/execute/990128-1.c new file mode 100644 index 00000000000..cfdab3e87e5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/990128-1.c @@ -0,0 +1,50 @@ +extern int printf (const char *,...); + +struct s { struct s *n; } *p; +struct s ss; +#define MAX 10 +struct s sss[MAX]; +int count = 0; + +void sub( struct s *p, struct s **pp ); +int look( struct s *p, struct s **pp ); + +main() +{ + struct s *pp; + struct s *next; + int i; + + p = &ss; + next = p; + for ( i = 0; i < MAX; i++ ) { + next->n = &sss[i]; + next = next->n; + } + next->n = 0; + + sub( p, &pp ); + if (count != MAX+2) + abort (); + + exit( 0 ); +} + +void sub( struct s *p, struct s **pp ) +{ + for ( ; look( p, pp ); ) { + if ( p ) + p = p->n; + else + break; + } +} + +int look( struct s *p, struct s **pp ) +{ + for ( ; p; p = p->n ) + ; + *pp = p; + count++; + return( 1 ); +}