summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/19_diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/19_diagnostics')
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc36
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_category/cons/default.cc33
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_category/operators/equal.cc34
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_category/operators/not_equal.cc34
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc45
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc60
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc61
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc44
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc33
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc40
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc40
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc48
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc60
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc61
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc47
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc32
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc43
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc43
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/cassert/macros.cc27
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/cerrno/macros.cc35
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/synopsis.cc33
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/types_std.cc33
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/system_error/34538.cc28
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc157
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc25
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc29
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc28
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/logic_error/what-1.cc58
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/logic_error/what-2.cc50
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/logic_error/what-3.cc71
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/logic_error/what-big.cc40
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc28
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-1.cc58
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-2.cc50
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-3.cc73
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-big.cc40
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/stdexcept.cc228
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc29
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc47
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc29
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc59
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc49
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc70
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc44
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc39
45 files changed, 2251 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc
new file mode 100644
index 000000000..12258cac0
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_test::test_category c1;
+ __gnu_test::test_category c2(c1); // { dg-error "deleted" }
+
+ return 0;
+}
+
+// { dg-prune-output "testsuite_error" }
+// { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/default.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/default.cc
new file mode 100644
index 000000000..cc9209265
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/default.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ // 1
+ __gnu_test::test_category c1;
+ __gnu_test::test_derived_category c2;
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/equal.cc
new file mode 100644
index 000000000..b9cb78886
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/equal.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_test::test_category c1;
+ __gnu_test::test_derived_category c2;
+ VERIFY( c1 == c1 );
+ VERIFY( !(c1 == c2) );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/not_equal.cc
new file mode 100644
index 000000000..405cebd75
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/operators/not_equal.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_test::test_category c1;
+ __gnu_test::test_derived_category c2;
+ VERIFY( !(c1 != c1) );
+ VERIFY( c1 != c2 );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc
new file mode 100644
index 000000000..7cd280aae
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ // 1
+ std::error_code e1;
+ VERIFY( e1.value() == 0 );
+ VERIFY( e1.category() == std::system_category() );
+
+ // 2
+ const __gnu_test::test_category cat;
+ std::error_code e2(e1.value(), cat);
+ VERIFY( e2.value() == e1.value() );
+ VERIFY( e2.category() == cat );
+
+ // 3
+ std::error_code e3(std::make_error_code(std::errc::operation_not_supported));
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::generic_category() );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc
new file mode 100644
index 000000000..9d5c2e333
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+enum my_errc { my_err = 0 };
+
+class my_error_category_impl
+: public std::error_category
+{
+public:
+ const char* name() const { return ""; }
+ std::string message(int) const { return ""; }
+} my_error_category_instance;
+
+std::error_code
+make_error_code(my_errc e)
+{
+ return std::error_code(static_cast<int>(e),
+ my_error_category_instance);
+}
+
+namespace std
+{
+ template<>
+ struct is_error_code_enum<my_errc>
+ : public true_type {};
+}
+
+// libstdc++/39882
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_code ec1(my_err);
+ VERIFY( ec1 == make_error_code(my_err) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc
new file mode 100644
index 000000000..880a93655
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc
@@ -0,0 +1,61 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+enum my_errc { my_err = 0 };
+
+class my_error_category_impl
+: public std::error_category
+{
+public:
+ const char* name() const { return ""; }
+ std::string message(int) const { return ""; }
+} my_error_category_instance;
+
+std::error_code
+make_error_code(my_errc e)
+{
+ return std::error_code(static_cast<int>(e),
+ my_error_category_instance);
+}
+
+namespace std
+{
+ template<>
+ struct is_error_code_enum<my_errc>
+ : public true_type {};
+}
+
+// libstdc++/39882
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_code ec2;
+ ec2 = my_err;
+ VERIFY( ec2 == make_error_code(my_err) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
new file mode 100644
index 000000000..2562b8dc5
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// unspecified bool operator positive tests
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ // 1
+ std::error_code e1;
+ if (static_cast<bool>(e1))
+ {
+ VERIFY( false );
+ }
+
+ // 2
+ std::error_code e2(std::make_error_code(std::errc::operation_not_supported));
+ if (static_cast<bool>(e2))
+ {
+ VERIFY( true );
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc
new file mode 100644
index 000000000..539dd891c
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc
@@ -0,0 +1,33 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ std::error_code e;
+ int i = e;
+
+ return i;
+}
+
+// { dg-error "cannot convert" "" { target *-*-* } 28 }
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc
new file mode 100644
index 000000000..880434c75
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+// unspecified bool operator positive tests
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_code e1;
+ std::error_code e2(std::make_error_code(std::errc::operation_not_supported));
+
+ VERIFY( e1 == e1 );
+ VERIFY( !(e1 == e2) );
+
+ const __gnu_test::test_category cat;
+ std::error_code e3(e2.value(), cat);
+ VERIFY( !(e2 == e3) );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc
new file mode 100644
index 000000000..bda2ee30e
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-08-22 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+// unspecified bool operator positive tests
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_code e1;
+ std::error_code e2(std::make_error_code(std::errc::operation_not_supported));
+
+ VERIFY( !(e1 != e1) );
+ VERIFY( e1 != e2 );
+
+ const __gnu_test::test_category cat;
+ std::error_code e3(e2.value(), cat);
+ VERIFY( e2 != e3 );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc
new file mode 100644
index 000000000..f42949778
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc
@@ -0,0 +1,48 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ // 1
+ std::error_condition e1;
+ VERIFY( e1.value() == 0 );
+ VERIFY( e1.category() == std::generic_category() );
+
+ // 2
+ const __gnu_test::test_category cat;
+ std::error_condition e2(e1.value(), cat);
+ VERIFY( e2.value() == e1.value() );
+ VERIFY( e2.category() == cat );
+
+ // 3
+ std::error_condition e3(std::errc::operation_not_supported);
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::generic_category() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc
new file mode 100644
index 000000000..7931f1740
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+enum my_errc { my_err = 0 };
+
+class my_error_category_impl
+: public std::error_category
+{
+public:
+ const char* name() const { return ""; }
+ std::string message(int) const { return ""; }
+} my_error_category_instance;
+
+std::error_condition
+make_error_condition(my_errc e)
+{
+ return std::error_condition(static_cast<int>(e),
+ my_error_category_instance);
+}
+
+namespace std
+{
+ template<>
+ struct is_error_condition_enum<my_errc>
+ : public true_type { };
+}
+
+// libstdc++/39881
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_condition ec1(my_err);
+ VERIFY( ec1 == make_error_condition(my_err) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc
new file mode 100644
index 000000000..0178a91c4
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc
@@ -0,0 +1,61 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+enum my_errc { my_err = 0 };
+
+class my_error_category_impl
+: public std::error_category
+{
+public:
+ const char* name() const { return ""; }
+ std::string message(int) const { return ""; }
+} my_error_category_instance;
+
+std::error_condition
+make_error_condition(my_errc e)
+{
+ return std::error_condition(static_cast<int>(e),
+ my_error_category_instance);
+}
+
+namespace std
+{
+ template<>
+ struct is_error_condition_enum<my_errc>
+ : public true_type { };
+}
+
+// libstdc++/39881
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_condition ec2;
+ ec2 = my_err;
+ VERIFY( ec2 == make_error_condition(my_err) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
new file mode 100644
index 000000000..62490fd2e
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// unspecified bool operator positive tests
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ // 1
+ std::error_condition e1;
+ if (static_cast<bool>(e1))
+ {
+ VERIFY( false );
+ }
+
+ // 2
+ std::error_condition e2(std::errc::operation_not_supported);
+ if (static_cast<bool>(e2))
+ {
+ VERIFY( true );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc
new file mode 100644
index 000000000..6b8d129d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc
@@ -0,0 +1,32 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int test01()
+{
+ std::error_condition e;
+ int i = e;
+
+ return i;
+}
+
+// { dg-error "cannot convert" "" { target *-*-* } 27 }
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc
new file mode 100644
index 000000000..d7f62bf09
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+// unspecified bool operator positive tests
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_condition e1;
+ std::error_condition e2(std::errc::operation_not_supported);
+
+ VERIFY( e1 == e1 );
+ VERIFY( !(e1 == e2) );
+
+ const __gnu_test::test_category cat;
+ std::error_condition e3(e2.value(), cat);
+ VERIFY( !(e2 == e3) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc
new file mode 100644
index 000000000..fed22ed4f
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_error.h>
+
+// unspecified bool operator positive tests
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::error_condition e1;
+ std::error_condition e2(std::errc::operation_not_supported);
+
+ VERIFY( !(e1 != e1) );
+ VERIFY( e1 != e2 );
+
+ const __gnu_test::test_category cat;
+ std::error_condition e3(e2.value(), cat);
+ VERIFY( e2 != e3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/cassert/macros.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/cassert/macros.cc
new file mode 100644
index 000000000..12ddd2799
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/cassert/macros.cc
@@ -0,0 +1,27 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cassert>
+
+namespace gnu
+{
+#ifndef assert
+ #error "assert_must_be_a_macro"
+#endif
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/cerrno/macros.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/cerrno/macros.cc
new file mode 100644
index 000000000..d82821b4f
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/cerrno/macros.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cerrno>
+
+namespace gnu
+{
+#ifndef EDOM
+ #error "EDOM_must_be_a_macro"
+#endif
+
+#ifndef ERANGE
+ #error "ERANGE_must_be_a_macro"
+#endif
+
+#ifndef errno
+ #error "errno_must_be_a_macro"
+#endif
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/synopsis.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/synopsis.cc
new file mode 100644
index 000000000..0035107bc
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/synopsis.cc
@@ -0,0 +1,33 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stdexcept>
+
+namespace std {
+ class logic_error;
+ class domain_error;
+ class invalid_argument;
+ class length_error;
+ class out_of_range;
+ class runtime_error;
+ class range_error;
+ class overflow_error;
+ class underflow_error;
+}
+
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/types_std.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/types_std.cc
new file mode 100644
index 000000000..bff018b94
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/types_std.cc
@@ -0,0 +1,33 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stdexcept>
+
+namespace gnu
+{
+ typedef std::logic_error t1;
+ typedef std::domain_error t2;
+ typedef std::invalid_argument t3;
+ typedef std::length_error t4;
+ typedef std::out_of_range t5;
+ typedef std::runtime_error t6;
+ typedef std::range_error t7;
+ typedef std::overflow_error t8;
+ typedef std::underflow_error t9;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/34538.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/34538.cc
new file mode 100644
index 000000000..e33a88e40
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/34538.cc
@@ -0,0 +1,28 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stdexcept>
+#include <system_error>
+
+// libstdc++/34538
+int main()
+{
+ throw std::invalid_argument("foo");
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
new file mode 100644
index 000000000..d480a09b8
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
@@ -0,0 +1,157 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+
+#define TEST_ERRC(x) errc x(errc::x); (void)x
+
+void test01()
+{
+ using std::errc;
+
+ TEST_ERRC(address_family_not_supported);
+ TEST_ERRC(address_in_use);
+ TEST_ERRC(address_not_available);
+ TEST_ERRC(already_connected);
+ TEST_ERRC(argument_list_too_long);
+ TEST_ERRC(argument_out_of_domain);
+ TEST_ERRC(bad_address);
+ TEST_ERRC(bad_file_descriptor);
+
+#ifdef _GLIBCXX_HAVE_EBADMSG
+ TEST_ERRC(bad_message);
+#endif
+
+ TEST_ERRC(broken_pipe);
+ TEST_ERRC(connection_aborted);
+ TEST_ERRC(connection_already_in_progress);
+ TEST_ERRC(connection_refused);
+ TEST_ERRC(connection_reset);
+ TEST_ERRC(cross_device_link);
+ TEST_ERRC(destination_address_required);
+ TEST_ERRC(device_or_resource_busy);
+ TEST_ERRC(directory_not_empty);
+ TEST_ERRC(executable_format_error);
+ TEST_ERRC(file_exists);
+ TEST_ERRC(file_too_large);
+ TEST_ERRC(filename_too_long);
+ TEST_ERRC(function_not_supported);
+ TEST_ERRC(host_unreachable);
+
+#ifdef _GLIBCXX_HAVE_EIDRM
+ TEST_ERRC(identifier_removed);
+#endif
+
+ TEST_ERRC(illegal_byte_sequence);
+ TEST_ERRC(inappropriate_io_control_operation);
+ TEST_ERRC(interrupted);
+ TEST_ERRC(invalid_argument);
+ TEST_ERRC(invalid_seek);
+ TEST_ERRC(io_error);
+ TEST_ERRC(is_a_directory);
+ TEST_ERRC(message_size);
+ TEST_ERRC(network_down);
+ TEST_ERRC(network_reset);
+ TEST_ERRC(network_unreachable);
+ TEST_ERRC(no_buffer_space);
+ TEST_ERRC(no_child_process);
+
+#ifdef _GLIBCXX_HAVE_ENOLINK
+ TEST_ERRC(no_link);
+#endif
+
+ TEST_ERRC(no_lock_available);
+
+#ifdef _GLIBCXX_HAVE_ENODATA
+ TEST_ERRC(no_message_available);
+#endif
+
+ TEST_ERRC(no_message);
+ TEST_ERRC(no_protocol_option);
+ TEST_ERRC(no_space_on_device);
+
+#ifdef _GLIBCXX_HAVE_ENOSR
+ TEST_ERRC(no_stream_resources);
+#endif
+
+ TEST_ERRC(no_such_device_or_address);
+ TEST_ERRC(no_such_device);
+ TEST_ERRC(no_such_file_or_directory);
+ TEST_ERRC(no_such_process);
+ TEST_ERRC(not_a_directory);
+ TEST_ERRC(not_a_socket);
+
+#ifdef _GLIBCXX_HAVE_ENOSTR
+ TEST_ERRC(not_a_stream);
+#endif
+
+ TEST_ERRC(not_connected);
+ TEST_ERRC(not_enough_memory);
+ TEST_ERRC(not_supported);
+
+#ifdef _GLIBCXX_HAVE_ECANCELED
+ TEST_ERRC(operation_canceled);
+#endif
+
+ TEST_ERRC(operation_in_progress);
+ TEST_ERRC(operation_not_permitted);
+ TEST_ERRC(operation_not_supported);
+ TEST_ERRC(operation_would_block);
+
+#ifdef _GLIBCXX_HAVE_EOWNERDEAD
+ TEST_ERRC(owner_dead);
+#endif
+
+ TEST_ERRC(permission_denied);
+
+#ifdef _GLIBCXX_HAVE_EPROTO
+ TEST_ERRC(protocol_error);
+#endif
+
+ TEST_ERRC(protocol_not_supported);
+ TEST_ERRC(read_only_file_system);
+ TEST_ERRC(resource_deadlock_would_occur);
+ TEST_ERRC(resource_unavailable_try_again);
+ TEST_ERRC(result_out_of_range);
+
+#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
+ TEST_ERRC(state_not_recoverable);
+#endif
+
+#ifdef _GLIBCXX_HAVE_ETIME
+ TEST_ERRC(stream_timeout);
+#endif
+
+#ifdef _GLIBCXX_HAVE_ETXTBSY
+ TEST_ERRC(text_file_busy);
+#endif
+
+ TEST_ERRC(timed_out);
+ TEST_ERRC(too_many_files_open_in_system);
+ TEST_ERRC(too_many_files_open);
+ TEST_ERRC(too_many_links);
+ TEST_ERRC(too_many_symbolic_link_levels);
+
+#ifdef _GLIBCXX_HAVE_EOVERFLOW
+ TEST_ERRC(value_too_large);
+#endif
+
+ TEST_ERRC(wrong_protocol_type);
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc
new file mode 100644
index 000000000..9698cf031
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+
+// { dg-error "upcoming ISO" "" { target *-*-* } 32 }
+
+
+
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc
new file mode 100644
index 000000000..f124e04ff
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+
+namespace gnu
+{
+ using std::system_error;
+ using std::error_code;
+ using std::error_category;
+ using std::system_category;
+}
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 000000000..a41b439d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/cons_virtual_derivation.cc
@@ -0,0 +1,28 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stdexcept>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef std::logic_error test_type;
+ __gnu_test::diamond_derivation<test_type, false>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-1.cc b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-1.cc
new file mode 100644
index 000000000..1c82da7b9
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-1.cc
@@ -0,0 +1,58 @@
+// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/1972
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string s("lack of sunlight, no water error");
+
+ // 1
+ std::logic_error obj1 = std::logic_error(s);
+
+ // 2
+ std::logic_error 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::domain_error x(s);
+
+ VERIFY( std::strcmp(x.what(), s.data()) == 0 );
+}
+
+int main(void)
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-2.cc b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-2.cc
new file mode 100644
index 000000000..094aa9e60
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-2.cc
@@ -0,0 +1,50 @@
+// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/2089
+class fuzzy_logic : public std::logic_error
+{
+public:
+ fuzzy_logic() : std::logic_error("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/19_diagnostics/logic_error/what-3.cc b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-3.cc
new file mode 100644
index 000000000..0656d42f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-3.cc
@@ -0,0 +1,71 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// test copy ctors, assignment operators, and persistence of member string data
+// libstdc++/1972
+// via Greg Bumgardner <bumgard@roguewave.com>
+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;
+ // Suppress unused warnings.
+ for (size_t i = 0; i < num; i++)
+ array[i]=array[i];
+}
+
+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::logic_error obj1(s);
+
+ // block 01
+ {
+ const std::string s2(strlit1);
+ std::logic_error obj2(s2);
+ obj1 = obj2;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
+
+ // block 02
+ {
+ const std::string s3(strlit2);
+ std::logic_error obj3 = std::logic_error(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/19_diagnostics/logic_error/what-big.cc b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-big.cc
new file mode 100644
index 000000000..87edf5c5e
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/what-big.cc
@@ -0,0 +1,40 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstring>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::logic_error 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/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 000000000..1eb2d66e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/cons_virtual_derivation.cc
@@ -0,0 +1,28 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stdexcept>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef std::runtime_error test_type;
+ __gnu_test::diamond_derivation<test_type, false>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-1.cc b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-1.cc
new file mode 100644
index 000000000..11d8ed617
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-1.cc
@@ -0,0 +1,58 @@
+// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/1972
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string s("lack of sunlight, no water error");
+
+ // 1
+ std::runtime_error obj1 = std::runtime_error(s);
+
+ // 2
+ std::runtime_error 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/19_diagnostics/runtime_error/what-2.cc b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-2.cc
new file mode 100644
index 000000000..b3a5ba5fd
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-2.cc
@@ -0,0 +1,50 @@
+// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/2089
+class fuzzy_logic : public std::runtime_error
+{
+public:
+ fuzzy_logic() : std::runtime_error("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/19_diagnostics/runtime_error/what-3.cc b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-3.cc
new file mode 100644
index 000000000..b252cea36
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-3.cc
@@ -0,0 +1,73 @@
+// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <stdexcept>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// test copy ctors, assignment operators, and persistence of member string data
+// libstdc++/1972
+// via Greg Bumgardner <bumgard@roguewave.com>
+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;
+ // Suppress unused warnings.
+ for (size_t i = 0; i < num; i++)
+ array[i]=array[i];
+}
+
+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::runtime_error obj1(s);
+
+ // block 01
+ {
+ const std::string s2(strlit1);
+ std::runtime_error obj2(s2);
+ obj1 = obj2;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
+
+ // block 02
+ {
+ const std::string s3(strlit2);
+ std::runtime_error obj3 = std::runtime_error(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/19_diagnostics/runtime_error/what-big.cc b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-big.cc
new file mode 100644
index 000000000..f9600cfbd
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/what-big.cc
@@ -0,0 +1,40 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstring>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::runtime_error 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/19_diagnostics/stdexcept.cc b/libstdc++-v3/testsuite/19_diagnostics/stdexcept.cc
new file mode 100644
index 000000000..128f0a5b5
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/stdexcept.cc
@@ -0,0 +1,228 @@
+// 2011-03-16 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2011
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ std::string s("error");
+
+ try
+ {
+ logic_error e1(s);
+ throw e1;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ domain_error e2(s);
+ throw e2;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ invalid_argument e3(s);
+ throw e3;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ length_error e4(s);
+ throw e4;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ out_of_range e5(s);
+ throw e5;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ runtime_error e6(s);
+ throw e6;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ range_error e7(s);
+ throw e7;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ overflow_error e8(s);
+ throw e8;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ underflow_error e9(s);
+ throw e9;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+}
+
+template<typename _Tp>
+struct extra_error : public _Tp
+{
+ extra_error(const std::string& s) : _Tp(s) { }
+};
+
+void test02()
+{
+ using namespace std;
+ std::string s("error");
+
+ try
+ {
+ extra_error<logic_error> e1(s);
+ throw e1;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<domain_error> e2(s);
+ throw e2;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<invalid_argument> e3(s);
+ throw e3;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<length_error> e4(s);
+ throw e4;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<out_of_range> e5(s);
+ throw e5;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<runtime_error> e6(s);
+ throw e6;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<range_error> e7(s);
+ throw e7;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<overflow_error> e8(s);
+ throw e8;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+
+ try
+ {
+ extra_error<underflow_error> e9(s);
+ throw e9;
+ }
+ catch(const exception& e)
+ {
+ s = e.what();
+ }
+}
+
+int main(void)
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc
new file mode 100644
index 000000000..a6ac7470c
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+
+// libstdc++/39880
+void test01()
+{
+ std::error_code ec;
+ if (ec == std::errc::not_supported)
+ { }
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc
new file mode 100644
index 000000000..4a145a993
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string s("too late: boulangerie out of pain au raisin");
+ const std::error_code
+ e(std::make_error_code(std::errc::operation_not_supported));
+
+ // 1
+ {
+ std::system_error err1(e, s);
+ VERIFY( err1.code() == e );
+ VERIFY( std::string(err1.what()).find(s) != std::string::npos );
+ }
+
+ // 2
+ {
+ std::system_error err2(95, std::system_category(), s);
+ VERIFY( err2.code() == std::error_code(95, std::system_category()) );
+ VERIFY( std::string((err2.what(), s)).find(s) != std::string::npos );
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc
new file mode 100644
index 000000000..d1afadffd
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef std::system_error test_type;
+ __gnu_test::diamond_derivation<test_type, true>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc
new file mode 100644
index 000000000..9899dfb7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc
@@ -0,0 +1,59 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+// libstdc++/1972
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ string s("lack of sunlight, no water error");
+
+ // 1
+ system_error obj1 = system_error(error_code(), s);
+
+ // 2
+ system_error obj2(error_code(), s);
+
+ VERIFY( string(obj1.what()).find(s.data()) != string::npos );
+ VERIFY( string(obj2.what()).find(s.data()) != string::npos );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ string s("lack of sunlight error");
+ system_error x(error_code(), s);
+
+ VERIFY( string(x.what()).find(s.data()) != string::npos );
+}
+
+int main(void)
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc
new file mode 100644
index 000000000..b5fe39cb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// libstdc++/2089
+class fuzzy_logic : public std::system_error
+{
+public:
+ fuzzy_logic() : std::system_error(std::error_code(), "whoa") { }
+};
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ try
+ { throw fuzzy_logic(); }
+ catch(const fuzzy_logic& obj)
+ { VERIFY( std::string(obj.what()).find("whoa") != std::string::npos ); }
+ catch(...)
+ { VERIFY( false ); }
+}
+
+int main(void)
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc
new file mode 100644
index 000000000..d1d2ffee4
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// test copy ctors, assignment operators, and persistence of member string data
+// libstdc++/1972
+// via Greg Bumgardner <bumgard@roguewave.com>
+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;
+ // Suppress unused warnings.
+ for (size_t i = 0; i < num; i++)
+ array[i]=array[i];
+}
+
+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::system_error obj1(std::error_code(), s);
+
+ // block 01
+ {
+ const std::string s2(strlit1);
+ std::system_error obj2(std::error_code(), s2);
+ obj1 = obj2;
+ }
+ allocate_on_stack();
+ VERIFY( std::string(obj1.what()).find(strlit1) != std::string::npos );
+
+ // block 02
+ {
+ const std::string s3(strlit2);
+ std::system_error obj3 = std::system_error(std::error_code(), s3);
+ obj1 = obj3;
+ }
+ allocate_on_stack();
+ VERIFY( std::string(obj1.what()).find(strlit2) != std::string::npos );
+}
+
+int main(void)
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
new file mode 100644
index 000000000..7c729c7f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// Make sure each invocation of what() doesn't grow the message.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string s("after nine thirty, this request cannot be met");
+
+ std::system_error obj =
+ std::system_error(std::make_error_code(std::errc::invalid_argument), s);
+ std::string s1(obj.what());
+ std::string s2(obj.what());
+ VERIFY( s1 == s2 );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc
new file mode 100644
index 000000000..351fc2914
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc
@@ -0,0 +1,39 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::system_error test_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string xxx(10000, 'x');
+ test_type t(std::error_code(), xxx);
+ VERIFY( std::string(t.what()).find(xxx) != std::string::npos );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}