[libcxx] r291922 - Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 10:08:23 PST 2017


Author: ericwf
Date: Fri Jan 13 12:08:23 2017
New Revision: 291922

URL: http://llvm.org/viewvc/llvm-project?rev=291922&view=rev
Log:
Revert "Rework fix for PR19460 - Use explicit bool as an extension instead."


Modified:
    libcxx/branches/release_40/include/__config
    libcxx/branches/release_40/include/experimental/string_view
    libcxx/branches/release_40/include/ios

Modified: libcxx/branches/release_40/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/__config?rev=291922&r1=291921&r2=291922&view=diff
==============================================================================
--- libcxx/branches/release_40/include/__config (original)
+++ libcxx/branches/release_40/include/__config Fri Jan 13 12:08:23 2017
@@ -772,7 +772,7 @@ template <unsigned> struct __static_asse
 #define _NOALIAS
 #endif
 
-#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
+#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
     (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
 #   define _LIBCPP_EXPLICIT explicit
 #else

Modified: libcxx/branches/release_40/include/experimental/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/experimental/string_view?rev=291922&r1=291921&r2=291922&view=diff
==============================================================================
--- libcxx/branches/release_40/include/experimental/string_view (original)
+++ libcxx/branches/release_40/include/experimental/string_view Fri Jan 13 12:08:23 2017
@@ -340,12 +340,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
         // [string.view.ops], string operations:
         template<class _Allocator>
         _LIBCPP_INLINE_VISIBILITY
-        // Clang's extended C++11 explict conversions don't work with
-        // string_view in C++03.
-#ifndef _LIBCPP_CXX03_LANG
-        _LIBCPP_EXPLICIT
-#endif
-        operator basic_string<_CharT, _Traits, _Allocator>() const
+        _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
         { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
 
         template<class _Allocator = allocator<_CharT> >

Modified: libcxx/branches/release_40/include/ios
URL: http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/ios?rev=291922&r1=291921&r2=291922&view=diff
==============================================================================
--- libcxx/branches/release_40/include/ios (original)
+++ libcxx/branches/release_40/include/ios Fri Jan 13 12:08:23 2017
@@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate)
     clear(__rdstate_);
 }
 
+#if defined(_LIBCPP_CXX03_LANG)
+struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+  typedef void (__cxx03_bool::*__bool_type)();
+  void __true_value() {}
+};
+#endif
+
 template <class _CharT, class _Traits>
 class _LIBCPP_TEMPLATE_VIS basic_ios
     : public ios_base
@@ -585,8 +592,18 @@ public:
     typedef typename traits_type::pos_type pos_type;
     typedef typename traits_type::off_type off_type;
 
+  // __true_value will generate undefined references when linking unless
+  // we give it internal linkage.
+
+#if defined(_LIBCPP_CXX03_LANG)
+    _LIBCPP_ALWAYS_INLINE
+    operator __cxx03_bool::__bool_type() const {
+        return !fail() ? &__cxx03_bool::__true_value : nullptr;
+    }
+#else
     _LIBCPP_ALWAYS_INLINE
     _LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
 
     _LIBCPP_ALWAYS_INLINE bool operator!() const    {return  fail();}
     _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return ios_base::rdstate();}




More information about the cfe-commits mailing list