From 0bb81a93acad9264d347ebf4a08648305b71298d Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 26 Jun 2007 15:58:45 +0000 Subject: [PATCH] testsuite_api.h: New. 2007-06-26 Benjamin Kosnik * testsuite/util/testsuite_api.h: New. * testsuite/27_io/ios_base/failure: Add. * testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc: New. * testsuite/27_io/ios_base/failure/what-1.cc: Same. * testsuite/27_io/ios_base/failure/what-2.cc: Same. * testsuite/27_io/ios_base/failure/what-big.cc: Same. * testsuite/27_io/ios_base/failure/what-3.cc: Same. * testsuite/19_diagnostics/logic_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/runtime_error/ cons_virtual_derivation.cc: Same. * testsuite/18_support/bad_alloc/cons_virtual_derivation.cc: Same. * testsuite/18_support/bad_cast/cons_virtual_derivation.cc: Same. * testsuite/18_support/bad_exception/cons_virtual_derivation.cc: Same. * testsuite/18_support/bad_typeid/cons_virtual_derivation.cc: Same. * testsuite/ext/concurrence_lock_error: New. * testsuite/ext/concurrence_lock_error/ cons_virtual_derivation.cc: Same. * testsuite/ext/forced_exception_error: New. * testsuite/ext/forced_exception_error/ cons_virtual_derivation.cc: Same. * testsuite/ext/concurrence_unlock_error: New. * testsuite/ext/concurrence_unlock_error/ cons_virtual_derivation.cc: Same. * testsuite/20_util/function_objects/bad_function_call: New. * testsuite/20_util/function_objects/bad_function_call/ cons_virtual_derivation.cc: Same. From-SVN: r126032 --- libstdc++-v3/ChangeLog | 30 +++++++ .../bad_alloc/cons_virtual_derivation.cc | 30 +++++++ .../bad_cast/cons_virtual_derivation.cc | 30 +++++++ .../bad_exception/cons_virtual_derivation.cc | 30 +++++++ .../bad_typeid/cons_virtual_derivation.cc | 30 +++++++ .../logic_error/cons_virtual_derivation.cc | 30 +++++++ .../runtime_error/cons_virtual_derivation.cc | 30 +++++++ .../cons_virtual_derivation.cc | 31 +++++++ .../failure/cons_virtual_derivation.cc | 30 +++++++ .../27_io/ios_base/failure/what-1.cc | 59 ++++++++++++++ .../27_io/ios_base/failure/what-2.cc | 51 ++++++++++++ .../27_io/ios_base/failure/what-3.cc | 71 ++++++++++++++++ .../27_io/ios_base/failure/what-big.cc | 41 ++++++++++ .../cons_virtual_derivation.cc | 30 +++++++ .../cons_virtual_derivation.cc | 30 +++++++ .../cons_virtual_derivation.cc | 30 +++++++ libstdc++-v3/testsuite/util/testsuite_api.h | 81 +++++++++++++++++++ 17 files changed, 664 insertions(+) create mode 100644 libstdc++-v3/testsuite/18_support/bad_alloc/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/18_support/bad_cast/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/18_support/bad_exception/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/18_support/bad_typeid/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/27_io/ios_base/failure/what-1.cc create mode 100644 libstdc++-v3/testsuite/27_io/ios_base/failure/what-2.cc create mode 100644 libstdc++-v3/testsuite/27_io/ios_base/failure/what-3.cc create mode 100644 libstdc++-v3/testsuite/27_io/ios_base/failure/what-big.cc create mode 100644 libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/ext/forced_exception_error/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/util/testsuite_api.h diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bfcfc777079..0007aaf5ed2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,35 @@ 2007-06-26 Benjamin Kosnik + * testsuite/util/testsuite_api.h: New. + * testsuite/27_io/ios_base/failure: Add. + * testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc: New. + * testsuite/27_io/ios_base/failure/what-1.cc: Same. + * testsuite/27_io/ios_base/failure/what-2.cc: Same. + * testsuite/27_io/ios_base/failure/what-big.cc: Same. + * testsuite/27_io/ios_base/failure/what-3.cc: Same. + * testsuite/19_diagnostics/logic_error/ + cons_virtual_derivation.cc: Same. + * testsuite/19_diagnostics/runtime_error/ + cons_virtual_derivation.cc: Same. + * testsuite/18_support/bad_alloc/cons_virtual_derivation.cc: Same. + * testsuite/18_support/bad_cast/cons_virtual_derivation.cc: Same. + * testsuite/18_support/bad_exception/cons_virtual_derivation.cc: Same. + * testsuite/18_support/bad_typeid/cons_virtual_derivation.cc: Same. + * testsuite/ext/concurrence_lock_error: New. + * testsuite/ext/concurrence_lock_error/ + cons_virtual_derivation.cc: Same. + * testsuite/ext/forced_exception_error: New. + * testsuite/ext/forced_exception_error/ + cons_virtual_derivation.cc: Same. + * testsuite/ext/concurrence_unlock_error: New. + * testsuite/ext/concurrence_unlock_error/ + cons_virtual_derivation.cc: Same. + * testsuite/20_util/function_objects/bad_function_call: New. + * testsuite/20_util/function_objects/bad_function_call/ + cons_virtual_derivation.cc: Same. + +2007-06-26 Benjamin Kosnik + * include/ext/throw_allocator.h: Fixes for -fno-exceptions. * testsuite/util/testsuite_shared.cc: Same. * testsuite/util/io/illegal_input_error.hpp: Same. diff --git a/libstdc++-v3/testsuite/18_support/bad_alloc/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/18_support/bad_alloc/cons_virtual_derivation.cc new file mode 100644 index 00000000000..dd0d09b6fb4 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/bad_alloc/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::bad_alloc test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/18_support/bad_cast/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/18_support/bad_cast/cons_virtual_derivation.cc new file mode 100644 index 00000000000..4efc3466cf9 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/bad_cast/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::bad_cast test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/18_support/bad_exception/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/18_support/bad_exception/cons_virtual_derivation.cc new file mode 100644 index 00000000000..b66ce7d43ed --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/bad_exception/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::bad_exception test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/18_support/bad_typeid/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/18_support/bad_typeid/cons_virtual_derivation.cc new file mode 100644 index 00000000000..0da3c9deac8 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/bad_typeid/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::bad_typeid test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc new file mode 100644 index 00000000000..5c936e27f16 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::logic_error test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc new file mode 100644 index 00000000000..86d5bb5ed71 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::runtime_error test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc new file mode 100644 index 00000000000..6cc46c02a51 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc @@ -0,0 +1,31 @@ +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++0x" } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::bad_function_call test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc new file mode 100644 index 00000000000..1819726a37b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef std::ios_base::failure test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/what-1.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-1.cc new file mode 100644 index 00000000000..1845d984d9a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-1.cc @@ -0,0 +1,59 @@ +// 2001-02-26 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 19.1 Exception classes + +#include +#include +#include +#include + +// libstdc++/1972 +void test01() +{ + bool test __attribute__((unused)) = true; + std::string s("lack of sunlight, no water error"); + + // 1 + std::ios_base::failure obj1 = std::ios_base::failure(s); + + // 2 + std::ios_base::failure obj2(s); + + VERIFY( std::strcmp(obj1.what(), s.data()) == 0 ); + VERIFY( std::strcmp(obj2.what(), s.data()) == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + std::string s("lack of sunlight error"); + std::range_error x(s); + + VERIFY( std::strcmp(x.what(), s.data()) == 0 ); +} + +int main(void) +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/what-2.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-2.cc new file mode 100644 index 00000000000..74fc46b1649 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-2.cc @@ -0,0 +1,51 @@ +// 2001-02-26 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 19.1 Exception classes + +#include +#include +#include +#include + +// libstdc++/2089 +class fuzzy_logic : public std::ios_base::failure +{ +public: + fuzzy_logic() : std::ios_base::failure("whoa") { } +}; + +void test03() +{ + bool test __attribute__((unused)) = true; + try + { throw fuzzy_logic(); } + catch(const fuzzy_logic& obj) + { VERIFY( std::strcmp("whoa", obj.what()) == 0 ); } + catch(...) + { VERIFY( false ); } +} + +int main(void) +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/what-3.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-3.cc new file mode 100644 index 00000000000..a8dd5355264 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-3.cc @@ -0,0 +1,71 @@ +// 2001-02-26 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 19.1 Exception classes + +#include +#include +#include +#include + +// test copy ctors, assignment operators, and persistence of member string data +// libstdc++/1972 +// via Greg Bumgardner +void allocate_on_stack(void) +{ + const size_t num = 512; + __extension__ char array[num]; + for (size_t i = 0; i < num; i++) + array[i]=0; +} + +void test04() +{ + bool test __attribute__((unused)) = true; + const std::string s("CA ISO emergency once again:immediate power down"); + const char* strlit1 = "wish I lived in Palo Alto"; + const char* strlit2 = "...or Santa Barbara"; + std::ios_base::failure obj1(s); + + // block 01 + { + const std::string s2(strlit1); + std::ios_base::failure obj2(s2); + obj1 = obj2; + } + allocate_on_stack(); + VERIFY( std::strcmp(strlit1, obj1.what()) == 0 ); + + // block 02 + { + const std::string s3(strlit2); + std::ios_base::failure obj3 = std::ios_base::failure(s3); + obj1 = obj3; + } + allocate_on_stack(); + VERIFY( std::strcmp(strlit2, obj1.what()) == 0 ); +} + +int main(void) +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/what-big.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-big.cc new file mode 100644 index 00000000000..1af73356d85 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/what-big.cc @@ -0,0 +1,41 @@ +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include +#include + +// Can construct and return 10k character error string. +void test01() +{ + typedef std::ios_base::failure test_type; + + bool test __attribute__((unused)) = true; + const std::string xxx(10000, 'x'); + test_type t(xxx); + VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 ); +} + +int main(void) +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc new file mode 100644 index 00000000000..07396b0b219 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef __gnu_cxx::__concurrence_lock_error test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc new file mode 100644 index 00000000000..ddc2c46b8ed --- /dev/null +++ b/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef __gnu_cxx::__concurrence_unlock_error test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/forced_exception_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/forced_exception_error/cons_virtual_derivation.cc new file mode 100644 index 00000000000..4ce8c673700 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/forced_exception_error/cons_virtual_derivation.cc @@ -0,0 +1,30 @@ +// { dg-do run { xfail *-*-* } } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +int main() +{ + typedef __gnu_cxx::forced_exception_error test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/util/testsuite_api.h b/libstdc++-v3/testsuite/util/testsuite_api.h new file mode 100644 index 00000000000..143ac67eff6 --- /dev/null +++ b/libstdc++-v3/testsuite/util/testsuite_api.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +// Exception testing utils for the C++ library testsuite. +// +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include + +#ifndef _TESTSUITE_EH +#define _TESTSUITE_EH 1 + +namespace __gnu_test +{ + // Checks for virtual public derivation in exception classes. + // See: + // http://www.boost.org/more/error_handling.html + struct bad_non_virtual : virtual public std::exception { }; + + template + struct diamond_derivation_base; + + template + struct diamond_derivation_base + { + struct diamond_derivation_error: bad_non_virtual, Exception + { + diamond_derivation_error() : bad_non_virtual(), Exception() { } + }; + }; + + template + struct diamond_derivation_base + { + struct diamond_derivation_error: bad_non_virtual, Exception + { + diamond_derivation_error() + : bad_non_virtual(), Exception("construct diamond") { } + }; + }; + + template + struct diamond_derivation: diamond_derivation_base + { + typedef diamond_derivation_base base_type; + typedef typename base_type::diamond_derivation_error error_type; + + static void test() + { + bool test __attribute__((unused)) = true; + try { throw error_type(); } + catch (std::exception const& e) { } + catch (...) + { VERIFY( false ); } + } + }; +} +#endif