This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libstc++/40296


Hi,

a little hackish, but should be ok for now and it's sufficiently
straightforward to go in 4_4-branch too.

Tested x86_64-linux, committed mainline and 4_4-branch.

Paolo.

///////////////////
2009-06-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/40296
	* libsupc++/exception_ptr.h (exception_ptr::operator!,
	exception_ptr::operator __safe_bool): Only declare when
	_GLIBCXX_EH_PTR_COMPAT is undefined.
	* libsupc++/eh_ptr.cc: Define _GLIBCXX_EH_PTR_COMPAT before including
	exception_ptr.
	* testsuite/18_support/exception_ptr/40296.cc: New.
	* testsuite/18_support/nested_exception/throw_with_nested.cc: Adjust.
	* testsuite/18_support/nested_exception/cons.cc: Likewise.
	* testsuite/18_support/nested_exception/nested_ptr.cc: Likewise.
	* testsuite/18_support/exception_ptr/current_exception.cc: Likewise.
Index: libsupc++/eh_ptr.cc
===================================================================
--- libsupc++/eh_ptr.cc	(revision 148119)
+++ libsupc++/eh_ptr.cc	(working copy)
@@ -26,6 +26,8 @@
 
 #ifdef _GLIBCXX_ATOMIC_BUILTINS_4
 
+#define _GLIBCXX_EH_PTR_COMPAT
+
 #include <exception>
 #include <exception_ptr.h>
 #include "unwind-cxx.h"
@@ -127,6 +129,7 @@
 }
 
 
+// Retained for compatibility with CXXABI_1.3.
 bool
 std::__exception_ptr::exception_ptr::operator!() const throw()
 {
@@ -134,6 +137,7 @@
 }
 
 
+// Retained for compatibility with CXXABI_1.3.
 std::__exception_ptr::exception_ptr::operator __safe_bool() const throw()
 {
   return _M_exception_object ? &exception_ptr::_M_safe_bool_dummy : 0;
@@ -235,4 +239,6 @@
   std::terminate ();
 }
 
+#undef _GLIBCXX_EH_PTR_COMPAT
+
 #endif
Index: libsupc++/exception_ptr.h
===================================================================
--- libsupc++/exception_ptr.h	(revision 148119)
+++ libsupc++/exception_ptr.h	(working copy)
@@ -77,10 +77,12 @@
   namespace __exception_ptr
   {
     bool 
-    operator==(const exception_ptr&, const exception_ptr&) throw() __attribute__ ((__pure__));
+    operator==(const exception_ptr&, const exception_ptr&)
+      throw() __attribute__ ((__pure__));
 
     bool 
-    operator!=(const exception_ptr&, const exception_ptr&) throw() __attribute__ ((__pure__));
+    operator!=(const exception_ptr&, const exception_ptr&)
+      throw() __attribute__ ((__pure__));
 
     class exception_ptr
     {
@@ -141,11 +143,15 @@
       }
 #endif
 
+#ifdef _GLIBCXX_EH_PTR_COMPAT
+      // Retained for compatibility with CXXABI_1.3.
       bool operator!() const throw() __attribute__ ((__pure__));
       operator __safe_bool() const throw();
+#endif
 
       friend bool 
-      operator==(const exception_ptr&, const exception_ptr&) throw() __attribute__ ((__pure__));
+      operator==(const exception_ptr&, const exception_ptr&)
+	throw() __attribute__ ((__pure__));
 
       const type_info*
       __cxa_exception_type() const throw() __attribute__ ((__pure__));
Index: testsuite/18_support/nested_exception/throw_with_nested.cc
===================================================================
--- testsuite/18_support/nested_exception/throw_with_nested.cc	(revision 148119)
+++ testsuite/18_support/nested_exception/throw_with_nested.cc	(working copy)
@@ -35,7 +35,7 @@
   }
   catch (const std::nested_exception& e)
   {
-    VERIFY( !e.nested_ptr() );
+    VERIFY( e.nested_ptr() == 0 );
     try
     {
       throw;
@@ -58,7 +58,7 @@
   }
   catch (const std::nested_exception& e)
   {
-    VERIFY( !e.nested_ptr() );
+    VERIFY( e.nested_ptr() == 0 );
     try
     {
       throw;
Index: testsuite/18_support/nested_exception/cons.cc
===================================================================
--- testsuite/18_support/nested_exception/cons.cc	(revision 148119)
+++ testsuite/18_support/nested_exception/cons.cc	(working copy)
@@ -27,7 +27,7 @@
 
   std::nested_exception e;
 
-  VERIFY( !e.nested_ptr() );
+  VERIFY( e.nested_ptr() == 0 );
 }
 
 void test02() 
Index: testsuite/18_support/nested_exception/nested_ptr.cc
===================================================================
--- testsuite/18_support/nested_exception/nested_ptr.cc	(revision 148119)
+++ testsuite/18_support/nested_exception/nested_ptr.cc	(working copy)
@@ -31,7 +31,7 @@
   }
   catch (const std::nested_exception& e)
   {
-    VERIFY( !e.nested_ptr() );
+    VERIFY( e.nested_ptr() == 0 );
   }
 }
 
Index: testsuite/18_support/exception_ptr/current_exception.cc
===================================================================
--- testsuite/18_support/exception_ptr/current_exception.cc	(revision 148119)
+++ testsuite/18_support/exception_ptr/current_exception.cc	(working copy)
@@ -31,7 +31,7 @@
   using namespace std;
 
   exception_ptr ep = current_exception();
-  VERIFY( !ep );
+  VERIFY( ep == 0 );
 }
 
 void test02()
@@ -43,7 +43,7 @@
     throw 0;
   } catch(...) {
     exception_ptr ep = current_exception();
-    VERIFY( ep );
+    VERIFY( ep != 0 );
   }
 }
 
@@ -56,7 +56,7 @@
     throw exception();
   } catch(std::exception&) {
     exception_ptr ep = current_exception();
-    VERIFY( ep );
+    VERIFY( ep != 0 );
   }
 }
 
Index: testsuite/18_support/exception_ptr/40296.cc
===================================================================
--- testsuite/18_support/exception_ptr/40296.cc	(revision 0)
+++ testsuite/18_support/exception_ptr/40296.cc	(revision 0)
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-atomic-builtins "" }
+
+// 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 <exception>
+
+// libstdc++/40296
+bool test01()
+{
+  std::exception_ptr p;
+
+  return (p == 0);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]