diff options
| -rw-r--r-- | libcxx/include/__config | 97 | ||||
| -rw-r--r-- | libcxx/include/cmath | 11 | ||||
| -rw-r--r-- | libcxx/include/cstddef | 36 | ||||
| -rw-r--r-- | libcxx/include/iterator | 2 | ||||
| -rw-r--r-- | libcxx/include/memory | 2 | ||||
| -rw-r--r-- | libcxx/include/string | 2 | ||||
| -rw-r--r-- | libcxx/include/thread | 11 | ||||
| -rw-r--r-- | libcxx/include/type_traits | 12 | ||||
| -rw-r--r-- | libcxx/include/utility | 6 | ||||
| -rw-r--r-- | libcxx/test/language.support/support.types/nullptr_t.pass.cpp | 21 | 
10 files changed, 165 insertions, 35 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config index a3518d9e318..42797365b47 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -73,31 +73,100 @@  #define _LIBCPP_ALWAYS_INLINE  __attribute__((__always_inline__)) -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 -#define _LIBCPP_MOVE +#if defined(__clang__) + +#if !(__has_feature(cxx_exceptions)) +#define _LIBCPP_NO_EXCEPTIONS  #endif -#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_STRONG_USING +#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + +#define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_NULLPTR  #define _LIBCPP_HAS_NO_STATIC_ASSERT +#define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_VARIADICS + +#else + +#if __has_feature(cxx_rvalue_references) +#define _LIBCPP_MOVE  #endif +#if !(__has_feature(cxx_decltype)) +#define _LIBCPP_HAS_NO_DECLTYPE +#endif + +#if !(__has_feature(cxx_deleted_functions)) +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#endif + +#if !(__has_feature(cxx_nullptr))  #define _LIBCPP_HAS_NO_NULLPTR +#endif -#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) +#if !(__has_feature(cxx_static_assert)) +#define _LIBCPP_HAS_NO_STATIC_ASSERT +#endif + +#if !(__has_feature(cxx_variadic_templates))  #define _LIBCPP_HAS_NO_VARIADICS +#endif + +#endif + +#elif defined(__GNUC__) + +#if !__EXCEPTIONS +#define _LIBCPP_NO_EXCEPTIONS +#endif + +#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE  #define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_NULLPTR +#define _LIBCPP_HAS_NO_STATIC_ASSERT +#define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_VARIADICS + +#else + +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 +#define _LIBCPP_MOVE +#endif + +#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) +#define _LIBCPP_HAS_NO_STATIC_ASSERT  #endif  #if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4) -#define _LIBCPP_HAS_NO_UNICODE_CHARS  #define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_VARIADICS  #endif -#if defined(__clang__) -#define _LIBCPP_HAS_NO_STRONG_USING +#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) +#define _LIBCPP_HAS_NO_NULLPTR  #endif -#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#endif + +#endif  #ifdef _LIBCPP_HAS_NO_STRONG_USING  #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { @@ -106,6 +175,7 @@  #else  #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {  #define _LIBCPP_END_NAMESPACE_STD  } } +#define _STD std::_LIBCPP_NAMESPACE  namespace std {  namespace _LIBCPP_NAMESPACE { @@ -113,12 +183,11 @@ namespace _LIBCPP_NAMESPACE {  using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));  } -#define _STD std::_LIBCPP_NAMESPACE  #endif  #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS -    typedef unsigned short char16_t; -    typedef unsigned int   char32_t; +typedef unsigned short char16_t; +typedef unsigned int   char32_t;  #endif  #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT @@ -133,13 +202,7 @@ template <unsigned> struct __static_assert_check {};  #endif  #ifdef _LIBCPP_HAS_NO_DECLTYPE -  #define decltype(x) __typeof__(x) - -#endif - -#if !__EXCEPTIONS -#define _LIBCPP_NO_EXCEPTIONS  #endif  #endif  // _LIBCPP_CONFIG diff --git a/libcxx/include/cmath b/libcxx/include/cmath index 1fe84796210..f133de98fe6 100644 --- a/libcxx/include/cmath +++ b/libcxx/include/cmath @@ -297,6 +297,12 @@ long double    truncl(long double x);  */ +// FIXME: work around for Clang with -std=C++0x on OSX/iOS  +#if defined(__clang__) && defined(__APPLE__) +# pragma push_macro("__STRICT_ANSI__") +# undef __STRICT_ANSI__ +#endif +  #include <__config>  #include <math.h>  #include <type_traits> @@ -1641,4 +1647,9 @@ using ::truncl;  _LIBCPP_END_NAMESPACE_STD +// FIXME: work around for Clang with -std=C++0x on OSX/iOS +#if defined(__clang__) && defined(__APPLE__) +# pragma pop_macro("__STRICT_ANSI__") +#endif +  #endif  // _LIBCPP_CMATH diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef index f6b34ad5c97..8cba5f8a2ec 100644 --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -78,6 +78,42 @@ struct nullptr_t      friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}      friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}      friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;} + +    template <typename _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, _Tp* __p) {return 0 == __p;} + +    template <typename _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator==(_Tp* __p, nullptr_t) {return __p == 0;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, _Tp* __p) {return 0 != __p;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator!=(_Tp* __p, nullptr_t) {return __p != 0;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, _Tp* __p) {return 0 < __p;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator<(_Tp* __p, nullptr_t) {return __p < 0;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, _Tp* __p) {return 0 <= __p;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator<=(_Tp* __p, nullptr_t) {return __p <= 0;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, _Tp* __p) {return 0 > __p;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator>(_Tp* __p, nullptr_t) {return __p > 0;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, _Tp* __p) {return 0 >= __p;} + +    template <class _Tp> +        friend _LIBCPP_ALWAYS_INLINE bool operator>=(_Tp* __p, nullptr_t) {return __p >= 0;}  };  inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);} diff --git a/libcxx/include/iterator b/libcxx/include/iterator index f2173e9e11d..877474bc94d 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -1615,7 +1615,7 @@ operator+(typename __debug_iter<_Container, _Iter>::difference_type __n,  #endif  // _LIBCPP_DEBUG -#ifdef _LIBCPP_MOVE +#if defined(_LIBCPP_MOVE) && !defined(_LIBCPP_HAS_NO_DECLTYPE)  template <class _C>  inline diff --git a/libcxx/include/memory b/libcxx/include/memory index 8af5ed766d7..3358a19f325 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1129,7 +1129,7 @@ struct uses_allocator  {  }; -#ifdef _LIBCPP_MOVE +#if defined(_LIBCPP_MOVE) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)  // uses-allocator construction diff --git a/libcxx/include/string b/libcxx/include/string index 3428fb84028..2ca5986358a 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1259,8 +1259,6 @@ private:      _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const {return __r_.second();}      _LIBCPP_INLINE_VISIBILITY bool __is_long() const {return bool(__r_.first().__s.__size_ & __short_mask);} -    _LIBCPP_INLINE_VISIBILITY void __set_long()  {__r_.first().__s.__size_ &= __short_mask;} -    _LIBCPP_INLINE_VISIBILITY void __set_short() {__r_.first().__s.__size_ |= ~__short_mask;}      _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s)  #if _LIBCPP_BIG_ENDIAN diff --git a/libcxx/include/thread b/libcxx/include/thread index 5fcd2c988de..6bf3189294f 100644 --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -178,9 +178,12 @@ class thread  {      pthread_t __t_; -#ifndef _LIBCPP_MOVE -    thread(const thread&); // = delete; -    thread& operator=(const thread&); // = delete; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +    thread(const thread&) = delete; +    thread& operator=(const thread&) = delete; +#else +    thread(const thread&); +    thread& operator=(const thread&);  #endif  public:      typedef __thread_id id; @@ -201,9 +204,7 @@ public:      ~thread();  #ifdef _LIBCPP_MOVE -    thread(const thread&) = delete;      thread(thread&& __t) : __t_(__t.__t_) {__t.__t_ = 0;} -    thread& operator=(const thread&) = delete;      thread& operator=(thread&& __t);  #endif diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 73b7a99fbd7..fc144716e3b 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1093,10 +1093,10 @@ private:  #else      static _Tp __t();      static _Up __u(); -    static bool __f();  #endif +    static bool __f();  public: -    typedef __typeof__(__f() ? __t() : __u()) type; +    typedef decltype(__f() ? __t() : __u()) type;  };  #else @@ -1135,7 +1135,10 @@ struct common_type<_Tp, _Up, _Vp...>  template <class _Tp>  inline _LIBCPP_INLINE_VISIBILITY  typename remove_reference<_Tp>::type&& -move(_Tp&& __t) {return __t;} +move(_Tp&& __t) +{ +    return static_cast<typename remove_reference<_Tp>::type&&>(__t); +}  template <class _Tp, class _Up,      class = typename _STD::enable_if< @@ -1148,8 +1151,7 @@ inline _LIBCPP_INLINE_VISIBILITY  _Tp&&  forward(_Up&& __t)  { -    return __t;  // to quiet spurious warning -//    return static_cast<_Tp&&>(__t); +    return static_cast<_Tp&&>(__t);  }  #else  // _LIBCPP_MOVE diff --git a/libcxx/include/utility b/libcxx/include/utility index 578d3130766..19e2893a3ac 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -223,6 +223,8 @@ struct pair                second(_STD::forward<_U2>(__u2))              {} +#ifndef _LIBCPP_HAS_NO_VARIADICS +      template<class _Tuple,               class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>          _LIBCPP_INLINE_VISIBILITY @@ -233,7 +235,6 @@ struct pair                                     typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))              {} -#ifndef _LIBCPP_HAS_NO_VARIADICS      template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>          pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,                                      tuple<_Args2...> __second_args) @@ -241,7 +242,6 @@ struct pair                     typename __make_tuple_indices<sizeof...(_Args1)>::type(),                     typename __make_tuple_indices<sizeof...(_Args2) >::type())              {} -#endif      template <class _Tuple,                class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type> @@ -256,6 +256,8 @@ struct pair              return *this;          } +#endif +  #else      template<class _U1, class _U2>          _LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p) diff --git a/libcxx/test/language.support/support.types/nullptr_t.pass.cpp b/libcxx/test/language.support/support.types/nullptr_t.pass.cpp index b169f1a75f8..204d740c3ec 100644 --- a/libcxx/test/language.support/support.types/nullptr_t.pass.cpp +++ b/libcxx/test/language.support/support.types/nullptr_t.pass.cpp @@ -24,9 +24,10 @@ int main()                    "sizeof(std::nullptr_t) == sizeof(void*)");      A* p = 0;      assert(p == nullptr); +    assert(nullptr == p); +#if !((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5)) +    // GCC 4.2 through 4.5 can't handle this      void (A::*pmf)() = 0; -#ifdef __clang__ -    // GCC 4.2 can't handle this      assert(pmf == nullptr);  #endif      int A::*pmd = 0; @@ -41,4 +42,20 @@ int main()      assert(!(nullptr != nullptr));      assert(!(nullptr < nullptr));      assert(!(nullptr > nullptr)); +    assert(!(&a1 == nullptr)); +    assert(!(nullptr == &a1)); +    assert(&a1 != nullptr); +    assert(nullptr != &a1); +    assert(nullptr < &a1); +    assert(nullptr <= &a1); +    assert(!(nullptr < p)); +    assert(nullptr <= p); +    assert(!(&a1 < nullptr)); +    assert(!(&a1 <= nullptr)); +    assert(!(p < nullptr)); +    assert(p <= nullptr); +    assert(!(nullptr > &a1)); +    assert(!(nullptr >= &a1)); +    assert(!(nullptr > p)); +    assert(nullptr >= p);  }  | 

