Index: testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc =================================================================== --- testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc (revision 0) +++ testsuite/27_io/ios_base/failure/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/27_io/ios_base/failure/what-1.cc =================================================================== --- testsuite/27_io/ios_base/failure/what-1.cc (revision 0) +++ testsuite/27_io/ios_base/failure/what-1.cc (revision 0) @@ -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; +} Index: testsuite/27_io/ios_base/failure/what-2.cc =================================================================== --- testsuite/27_io/ios_base/failure/what-2.cc (revision 0) +++ testsuite/27_io/ios_base/failure/what-2.cc (revision 0) @@ -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; +} Index: testsuite/27_io/ios_base/failure/what-big.cc =================================================================== --- testsuite/27_io/ios_base/failure/what-big.cc (revision 0) +++ testsuite/27_io/ios_base/failure/what-big.cc (revision 0) @@ -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; +} Index: testsuite/27_io/ios_base/failure/what-3.cc =================================================================== --- testsuite/27_io/ios_base/failure/what-3.cc (revision 0) +++ testsuite/27_io/ios_base/failure/what-3.cc (revision 0) @@ -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; +} Index: testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc =================================================================== --- testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc (revision 0) +++ testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc =================================================================== --- testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc (revision 0) +++ testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/18_support/bad_alloc/cons_virtual_derivation.cc =================================================================== --- testsuite/18_support/bad_alloc/cons_virtual_derivation.cc (revision 0) +++ testsuite/18_support/bad_alloc/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/18_support/bad_cast/cons_virtual_derivation.cc =================================================================== --- testsuite/18_support/bad_cast/cons_virtual_derivation.cc (revision 0) +++ testsuite/18_support/bad_cast/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/18_support/bad_exception/cons_virtual_derivation.cc =================================================================== --- testsuite/18_support/bad_exception/cons_virtual_derivation.cc (revision 0) +++ testsuite/18_support/bad_exception/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/18_support/bad_typeid/cons_virtual_derivation.cc =================================================================== --- testsuite/18_support/bad_typeid/cons_virtual_derivation.cc (revision 0) +++ testsuite/18_support/bad_typeid/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc =================================================================== --- testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc (revision 0) +++ testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/ext/forced_exception_error/cons_virtual_derivation.cc =================================================================== --- testsuite/ext/forced_exception_error/cons_virtual_derivation.cc (revision 0) +++ testsuite/ext/forced_exception_error/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc =================================================================== --- testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc (revision 0) +++ testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc (revision 0) @@ -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; +} Index: testsuite/util/testsuite_api.h =================================================================== --- testsuite/util/testsuite_api.h (revision 0) +++ testsuite/util/testsuite_api.h (revision 0) @@ -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 Index: testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc =================================================================== --- testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc (revision 0) +++ testsuite/20_util/function_objects/bad_function_call/cons_virtual_derivation.cc (revision 0) @@ -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; +}