56d343
2015-09-03  Jonathan Wakely  <jwakely@redhat.com>
56d343
56d343
	Backport from mainline
56d343
	2015-04-27  Dmitry Prokoptsev  <dprokoptsev@gmail.com>
56d343
		    Michael Hanselmann  <public@hansmi.ch>
56d343
56d343
	PR libstdc++/62258
56d343
	* libsupc++/eh_ptr.cc (rethrow_exception): Increment count of
56d343
	uncaught exceptions.
56d343
	* testsuite/18_support/exception_ptr/62258.cc: New.
56d343
56d343
--- libstdc++-v3/libsupc++/eh_ptr.cc	(revision 227455)
56d343
+++ libstdc++-v3/libsupc++/eh_ptr.cc	(revision 227456)
56d343
@@ -245,6 +245,9 @@ std::rethrow_exception(std::exception_pt
56d343
   __GXX_INIT_DEPENDENT_EXCEPTION_CLASS(dep->unwindHeader.exception_class);
56d343
   dep->unwindHeader.exception_cleanup = __gxx_dependent_exception_cleanup;
56d343
 
56d343
+  __cxa_eh_globals *globals = __cxa_get_globals ();
56d343
+  globals->uncaughtExceptions += 1;
56d343
+
56d343
 #ifdef _GLIBCXX_SJLJ_EXCEPTIONS
56d343
   _Unwind_SjLj_RaiseException (&dep->unwindHeader);
56d343
 #else
56d343
--- libstdc++-v3/testsuite/18_support/exception_ptr/62258.cc	(revision 0)
56d343
+++ libstdc++-v3/testsuite/18_support/exception_ptr/62258.cc	(revision 227456)
56d343
@@ -0,0 +1,61 @@
56d343
+// { dg-options "-std=gnu++11" }
56d343
+// { dg-require-atomic-builtins "" }
56d343
+
56d343
+// Copyright (C) 2015 Free Software Foundation, Inc.
56d343
+//
56d343
+// This file is part of the GNU ISO C++ Library.  This library is free
56d343
+// software; you can redistribute it and/or modify it under the
56d343
+// terms of the GNU General Public License as published by the
56d343
+// Free Software Foundation; either version 3, or (at your option)
56d343
+// any later version.
56d343
+
56d343
+// This library is distributed in the hope that it will be useful,
56d343
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
56d343
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
56d343
+// GNU General Public License for more details.
56d343
+
56d343
+// You should have received a copy of the GNU General Public License along
56d343
+// with this library; see the file COPYING3.  If not see
56d343
+// <http://www.gnu.org/licenses/>.
56d343
+
56d343
+// PR libstdc++/62258
56d343
+
56d343
+#include <exception>
56d343
+#include <testsuite_hooks.h>
56d343
+
56d343
+struct check_on_destruct
56d343
+{
56d343
+  ~check_on_destruct();
56d343
+};
56d343
+
56d343
+check_on_destruct::~check_on_destruct()
56d343
+{
56d343
+  VERIFY(std::uncaught_exception());
56d343
+}
56d343
+
56d343
+int main ()
56d343
+{
56d343
+  VERIFY(!std::uncaught_exception());
56d343
+
56d343
+  try
56d343
+    {
56d343
+      check_on_destruct check;
56d343
+
56d343
+      try
56d343
+        {
56d343
+          throw 1;
56d343
+        }
56d343
+      catch (...)
56d343
+        {
56d343
+          VERIFY(!std::uncaught_exception());
56d343
+
56d343
+          std::rethrow_exception(std::current_exception());
56d343
+        }
56d343
+    }
56d343
+  catch (...)
56d343
+    {
56d343
+      VERIFY(!std::uncaught_exception());
56d343
+    }
56d343
+
56d343
+  VERIFY(!std::uncaught_exception());
56d343
+}