From 846f046709389edeb34698ac0198b58c8f01a6de Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Fri, 14 Sep 2001 22:33:58 +0000 Subject: [PATCH] * gcc.c-torture/execute/20010915-1.c: New test. From-SVN: r45618 --- gcc/testsuite/ChangeLog | 4 ++ .../gcc.c-torture/execute/20010915-1.c | 71 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20010915-1.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 86c3c014b05..89bd954dbfe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-09-15 Hans-Peter Nilsson + + * gcc.c-torture/execute/20010915-1.c: New test. + 2001-09-14 Janis Johnson * g77.dg/bprob: New directory. diff --git a/gcc/testsuite/gcc.c-torture/execute/20010915-1.c b/gcc/testsuite/gcc.c-torture/execute/20010915-1.c new file mode 100644 index 00000000000..56155659f5b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20010915-1.c @@ -0,0 +1,71 @@ +/* Bug in reorg.c, deleting the "++" in the last loop in main. + Origin: . */ + +extern void f (void); +extern int x (int, char **); +extern int r (const char *); +extern char *s (char *, char **); +extern char *m (char *); +char *u; +char *h; +int check = 0; +int o = 0; + +int main (int argc, char **argv) +{ + char *args[] = {"a", "b", "c", "d", "e"}; + if (x (5, args) != 0 || check != 2 || o != 5) + abort (); + exit (0); +} + +int x (int argc, char **argv) +{ + int opt = 0; + char *g = 0; + char *p = 0; + + if (argc > o && argc > 2 && argv[o]) + { + g = s (argv[o], &p); + if (g) + { + *g++ = '\0'; + h = s (g, &p); + if (g == p) + h = m (g); + } + u = s (argv[o], &p); + if (argv[o] == p) + u = m (argv[o]); + } + else + abort (); + + while (++o < argc) + if (r (argv[o]) == 0) + return 1; + + return 0; +} + +char *m (char *x) { abort (); } +char *s (char *v, char **pp) +{ + if (strcmp (v, "a") != 0 || check++ > 1) + abort; + *pp = v+1; + return 0; +} + +int r (const char *f) +{ + static char c[2] = "b"; + static int cnt = 0; + + if (*f != *c || f[1] != c[1] || cnt > 3) + abort (); + c[0]++; + cnt++; + return 1; +}