diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1283,10 +1283,6 @@ # define _LIBCPP_SAFE_STATIC #endif -#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 -#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF -#endif - #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) # define _LIBCPP_DIAGNOSE_WARNING(...) \ __attribute__((diagnose_if(__VA_ARGS__, "warning"))) diff --git a/libcxx/include/__memory/addressof.h b/libcxx/include/__memory/addressof.h --- a/libcxx/include/__memory/addressof.h +++ b/libcxx/include/__memory/addressof.h @@ -21,8 +21,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF - template inline _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY @@ -32,19 +30,6 @@ return __builtin_addressof(__x); } -#else - -template -inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return reinterpret_cast<_Tp *>( - const_cast(&reinterpret_cast(__x))); -} - -#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF - #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) // Objective-C++ Automatic Reference Counting uses qualified pointers // that require special addressof() signatures. When diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -883,11 +883,7 @@ operator->() const { _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value"); -#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF return _VSTD::addressof(this->__get()); -#else - return __operator_arrow(__has_operator_addressof{}, this->__get()); -#endif } _LIBCPP_INLINE_VISIBILITY @@ -896,11 +892,7 @@ operator->() { _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value"); -#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF return _VSTD::addressof(this->__get()); -#else - return __operator_arrow(__has_operator_addressof{}, this->__get()); -#endif } _LIBCPP_INLINE_VISIBILITY @@ -1006,23 +998,6 @@ } using __base::reset; - -private: - template - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR_AFTER_CXX17 _Up* - __operator_arrow(true_type, _Up& __x) - { - return _VSTD::addressof(__x); - } - - template - _LIBCPP_INLINE_VISIBILITY - static constexpr _Up* - __operator_arrow(false_type, _Up& __x) - { - return &__x; - } }; #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -4349,40 +4349,6 @@ typename __sfinae_underlying_type<_Tp>::__promoted_type __convert_to_integral(_Tp __val) { return __val; } -#ifndef _LIBCPP_CXX03_LANG - -template -struct __has_operator_addressof_member_imp -{ - template - static auto __test(int) - -> typename __select_2nd().operator&()), true_type>::type; - template - static auto __test(long) -> false_type; - - static const bool value = decltype(__test<_Tp>(0))::value; -}; - -template -struct __has_operator_addressof_free_imp -{ - template - static auto __test(int) - -> typename __select_2nd())), true_type>::type; - template - static auto __test(long) -> false_type; - - static const bool value = decltype(__test<_Tp>(0))::value; -}; - -template -struct __has_operator_addressof - : public integral_constant::value - || __has_operator_addressof_free_imp<_Tp>::value> -{}; - -#endif // _LIBCPP_CXX03_LANG - // is_scoped_enum [meta.unary.prop] #if _LIBCPP_STD_VER > 20 diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -199,9 +199,7 @@ #endif #if _LIBCPP_STD_VER > 14 -# if !defined(_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF) -# define __cpp_lib_addressof_constexpr 201603L -# endif +# define __cpp_lib_addressof_constexpr 201603L # define __cpp_lib_allocator_traits_is_always_equal 201411L # define __cpp_lib_any 201606L # define __cpp_lib_apply 201603L diff --git a/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03 - -// type_traits - -// extension - -// template struct __has_operator_addressof - - -#include - -#include "test_macros.h" - - -struct A -{ -}; - -struct B -{ - constexpr B* operator&() const; -}; - -struct D; - -struct C -{ - template - D operator,(U&&); -}; - -struct E -{ - constexpr C operator&() const; -}; - -struct F {}; -constexpr F* operator&(F const &) { return nullptr; } - -struct G {}; -constexpr G* operator&(G &&) { return nullptr; } - -struct H {}; -constexpr H* operator&(H const &&) { return nullptr; } - -struct J -{ - constexpr J* operator&() const &&; -}; - - -int main(int, char**) -{ - static_assert(std::__has_operator_addressof::value == false, ""); - static_assert(std::__has_operator_addressof::value == false, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - static_assert(std::__has_operator_addressof::value == true, ""); - - return 0; -} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp @@ -178,17 +178,11 @@ #elif TEST_STD_VER == 17 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++17" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++17" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++17" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++17" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal @@ -274,17 +268,11 @@ #elif TEST_STD_VER == 20 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++20" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++20" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++20" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++20" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal @@ -424,17 +412,11 @@ #elif TEST_STD_VER > 20 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++2b" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++2b" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++2b" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++2b" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -1285,17 +1285,11 @@ #elif TEST_STD_VER == 17 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++17" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++17" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++17" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++17" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal @@ -2091,17 +2085,11 @@ #elif TEST_STD_VER == 20 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++20" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++20" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++20" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++20" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal @@ -3254,17 +3242,11 @@ #elif TEST_STD_VER > 20 -# if TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 -# ifndef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should be defined in c++2b" -# endif -# if __cpp_lib_addressof_constexpr != 201603L -# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++2b" -# endif -# else -# ifdef __cpp_lib_addressof_constexpr -# error "__cpp_lib_addressof_constexpr should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!" -# endif +# ifndef __cpp_lib_addressof_constexpr +# error "__cpp_lib_addressof_constexpr should be defined in c++2b" +# endif +# if __cpp_lib_addressof_constexpr != 201603L +# error "__cpp_lib_addressof_constexpr should have the value 201603L in c++2b" # endif # ifndef __cpp_lib_allocator_traits_is_always_equal diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -66,8 +66,6 @@ "name": "__cpp_lib_addressof_constexpr", "values": { "c++17": 201603 }, "headers": ["memory"], - "test_suite_guard": "TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700", - "libcxx_guard": "!defined(_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF)", }, { "name": "__cpp_lib_allocator_traits_is_always_equal", "values": { "c++17": 201411 },