Commit f07e3e86 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r294133 and r294142:

------------------------------------------------------------------------
r294133 | marshall | 2017-02-05 12:06:38 -0800 (Sun, 05 Feb 2017) | 1 line

Change the base class of std::bad_optional_access.  This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona. I am making this change now in anticipation, and will get it into 4.0, because (a) 4.0 is the first release with std::optional, and (b) I don't want to make an ABI-change later, when the user base should be significantly larger. Note that I didn't change std::experimental::bad_optional_access, because that's still specified to derive from std::logic_error.
------------------------------------------------------------------------

------------------------------------------------------------------------
r294142 | marshall | 2017-02-05 12:52:32 -0800 (Sun, 05 Feb 2017) | 1 line

Restore the _NOEXCEPT on the dtor of bad_optional_access. Destructors are noexcept by default, so it's not really needed, but the other exception classes have the _NOEXCEPT, and gcc complains if these are missing. I think we should remove them all - but not today.
------------------------------------------------------------------------

llvm-svn: 294249
parent 95582bf2
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -160,14 +160,12 @@ namespace std // purposefully not using versioning namespace
{

class _LIBCPP_EXCEPTION_ABI bad_optional_access
    : public logic_error
    : public exception
{
public:
    _LIBCPP_INLINE_VISIBILITY
    bad_optional_access() : logic_error("bad optional access") {}

    // Get the key function ~bad_optional_access() into the dylib
    virtual ~bad_optional_access() _NOEXCEPT;
    virtual const char* what() const _NOEXCEPT;
};

}  // std
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@ namespace std

bad_optional_access::~bad_optional_access() _NOEXCEPT = default;

const char* bad_optional_access::what() const _NOEXCEPT {
  return "bad_optional_access";
  }

} // std

_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
+3 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

// <optional>

// class bad_optional_access : public logic_error
// class bad_optional_access : public exception

#include <optional>
#include <type_traits>
@@ -20,6 +20,6 @@ int main()
{
    using std::bad_optional_access;

    static_assert(std::is_base_of<std::logic_error, bad_optional_access>::value, "");
    static_assert(std::is_convertible<bad_optional_access*, std::logic_error*>::value, "");
    static_assert(std::is_base_of<std::exception, bad_optional_access>::value, "");
    static_assert(std::is_convertible<bad_optional_access*, std::exception*>::value, "");
}