From 96e1d96c911f97e775adb93ab03020d90035be42 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 10 Apr 2000 16:22:52 +0000 Subject: [PATCH] * g++.old-deja/g++.eh/catchptr1.C: New test. From-SVN: r33062 --- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C | 234 ++++++++++++++++++ 2 files changed, 238 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a3136e6c33..48a4fdb5739 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-04-10 Nathan Sidwell + + * g++.old-deja/g++.eh/catchptr1.C: New test. + 2000-04-09 Nathan Sidwell * g++.old-deja/g++.abi/cxa_vec.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C b/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C new file mode 100644 index 00000000000..3c74b8d3496 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C @@ -0,0 +1,234 @@ +// Test pointer chain catching +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Apr 2000 + +#include + +void fn () {}; +struct A {void fn () {}}; +static int var = 1; +static const int const_var = 2; + +struct B; +struct C; + +int test0 () +{ + try + { + throw &fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } +} + +int test1 () +{ + try + { + throw &A::fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } +} + +int test2 () +{ + try + { + throw &var; + } + catch (void *) + { + // should decay to void * + return 0; + } + catch (...) + { + return 1; + } +} + +int test3 () +{ + try + { + throw &var; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 1; + } +} + +int test4 () +{ + try + { + throw &const_var; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 2; + } +} + +int test5 () +{ + try + { + throw (void ***)0; + } + catch (void ***) + { + return 0; + } + catch (...) + { + return 1; + } +} + +int test6 () +{ + try + { + throw (void const* const* const*)0; + } + catch (void ***) + { + return 1; + } + catch (void * const* const*) + { + return 2; + } + catch (void const* * const*) + { + return 3; + } + catch (void const* const* *) + { + return 4; + } + catch (void const* const* const *) + { + return 0; + } + catch (...) + { + return 1; + } +} + +int test7 () +{ + try + { + throw (void ***)0; + } + catch (void const* const**) + { + return 1; + } + catch (void const** const *) + { + return 2; + } + catch (void * const* const *) + { + return 0; + } + catch (...) + { + return 3; + } +} + +#if 0 +int test8 () +{ + try + { + throw (B **)0; + } + catch (C **) + { + return 1; + } + catch (B **) + { + return 0; + } + catch (...) + { + return 2; + } +} +#endif + +static int (*tests[])() = +{ + test0, + test1, + test2, + test3, + test4, + + test5, + test6, + test7, + +#if 0 + test8, +#endif + + NULL +}; + +int main () +{ + int ix; + int errors = 0; + + for (ix = 0; tests[ix]; ix++) + { + int n = tests[ix] (); + + if (n) + { + printf ("test %d failed %d\n", ix, n); + errors++; + } + } + return errors; +}