[libcxx-commits] [libcxx] 77b3205 - [libc++] Assume that compilers support extended constexpr in C++14 mode

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 25 05:41:20 PDT 2021


Author: Louis Dionne
Date: 2021-08-25T08:41:07-04:00
New Revision: 77b32055ec8d103a1ddfcc3b80c9f72902aaf6ff

URL: https://github.com/llvm/llvm-project/commit/77b32055ec8d103a1ddfcc3b80c9f72902aaf6ff
DIFF: https://github.com/llvm/llvm-project/commit/77b32055ec8d103a1ddfcc3b80c9f72902aaf6ff.diff

LOG: [libc++] Assume that compilers support extended constexpr in C++14 mode

We don't support any compiler that doesn't support C++14 constexpr when
compiling in C++14 mode anymore, so we can just assume that we have C++14
extended constexpr when compiling in C++14 mode. This allows us to remove
some workarounds for older compilers.

Differential Revision: https://reviews.llvm.org/D108638

Added: 
    

Modified: 
    libcxx/include/__config
    libcxx/test/libcxx/selftest/test_macros.pass.cpp
    libcxx/test/support/test_macros.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 23a091aa153f6..f57ad8fba4c75 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -492,10 +492,6 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_HAS_BLOCKS_RUNTIME
 #endif
 
-#if !(__has_feature(cxx_relaxed_constexpr))
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#endif
-
 #if !(__has_feature(cxx_variable_templates))
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
@@ -542,11 +538,6 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NO_EXCEPTIONS
 #endif
 
-// Determine if GCC supports relaxed constexpr
-#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#endif
-
 // GCC 5 supports variable templates
 #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@@ -575,7 +566,6 @@ typedef __char32_t char32_t;
 #error "MSVC versions prior to Visual Studio 2015 are not supported"
 #endif
 
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
@@ -1044,19 +1034,19 @@ typedef unsigned int   char32_t;
 #  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
 #endif
 
-#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 11
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
-#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 14
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX14
 #endif
 
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 17
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -1096,10 +1086,10 @@ typedef unsigned int   char32_t;
 #  define _LIBCPP_INLINE_VAR
 #endif
 
-#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#   define _LIBCPP_CONSTEXPR_IF_NODEBUG
-#else
+#if !defined(_LIBCPP_DEBUG) && _LIBCPP_STD_VER > 11
 #   define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
+#else
+#   define _LIBCPP_CONSTEXPR_IF_NODEBUG
 #endif
 
 #if __has_attribute(no_destroy)

diff  --git a/libcxx/test/libcxx/selftest/test_macros.pass.cpp b/libcxx/test/libcxx/selftest/test_macros.pass.cpp
index d7baeb2f99fa6..e4dd2812678ee 100644
--- a/libcxx/test/libcxx/selftest/test_macros.pass.cpp
+++ b/libcxx/test/libcxx/selftest/test_macros.pass.cpp
@@ -33,16 +33,6 @@ void test_noexcept() TEST_NOEXCEPT
 void test_libcxx_macros()
 {
 //  ===== C++14 features =====
-//  defined(TEST_HAS_EXTENDED_CONSTEXPR)  != defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#ifdef TEST_HAS_EXTENDED_CONSTEXPR
-# ifdef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#  error "TEST_EXTENDED_CONSTEXPR mismatch (1)"
-# endif
-#else
-# ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#  error "TEST_EXTENDED_CONSTEXPR mismatch (2)"
-# endif
-#endif
 
 //  defined(TEST_HAS_VARIABLE_TEMPLATES) != defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 #ifdef TEST_HAS_VARIABLE_TEMPLATES

diff  --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 16012613c4e0a..a7ff51839ee45 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -165,7 +165,6 @@
 
 /* Features that were introduced in C++14 */
 #if TEST_STD_VER >= 14
-#define TEST_HAS_EXTENDED_CONSTEXPR
 #define TEST_HAS_VARIABLE_TEMPLATES
 #endif
 


        


More information about the libcxx-commits mailing list