From dbf7ae6f9b8406d1a2a905b2e14c8b5bdcf569b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=C3=A1nchez?= Date: Tue, 20 Dec 2022 18:06:03 +0000 Subject: [PATCH] Fix up C++ version detection macros and cmake tests. --- Eigen/src/Core/util/Macros.h | 6 +++--- test/CMakeLists.txt | 13 +------------ test/constexpr.cpp | 4 ++-- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 1b0f226fe..4b8b277f2 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -650,11 +650,11 @@ // The macro EIGEN_COMP_CXXVER defines the c++ version expected by the compiler. // For instance, if compiling with gcc and -std=c++17, then EIGEN_COMP_CXXVER // is defined to 17. -#if EIGEN_CPLUSPLUS > 201703L +#if EIGEN_CPLUSPLUS >= 202002L #define EIGEN_COMP_CXXVER 20 -#elif EIGEN_CPLUSPLUS > 201402L +#elif EIGEN_CPLUSPLUS >= 201703L #define EIGEN_COMP_CXXVER 17 -#elif EIGEN_CPLUSPLUS > 201103L +#elif EIGEN_CPLUSPLUS >= 201402L #define EIGEN_COMP_CXXVER 14 #elif EIGEN_CPLUSPLUS >= 201103L #define EIGEN_COMP_CXXVER 11 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fb7165c5d..223a9f1ae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -185,18 +185,7 @@ ei_add_test(io) ei_add_test(packetmath "-DEIGEN_FAST_MATH=1") ei_add_test(vectorization_logic) ei_add_test(basicstuff) -ei_add_test_internal(constexpr constexpr_cxx14) -target_compile_features(constexpr_cxx14 PRIVATE cxx_std_14) -if ("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - # C++17 changes some rules related to constexpr, check that it works - ei_add_test_internal(constexpr constexpr_cxx17) - target_compile_features(constexpr_cxx17 PRIVATE cxx_std_17) -endif() -if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - # C++20 changes some rules related to constexpr, check that it works - ei_add_test_internal(constexpr constexpr_cxx20) - target_compile_features(constexpr_cxx20 PRIVATE cxx_std_20) -endif() +ei_add_test(constexpr) ei_add_test(constructor) ei_add_test(linearstructure) ei_add_test(integer_types) diff --git a/test/constexpr.cpp b/test/constexpr.cpp index a327c14c4..b8f0b0920 100644 --- a/test/constexpr.cpp +++ b/test/constexpr.cpp @@ -15,7 +15,7 @@ EIGEN_DECLARE_TEST(constexpr) { // until after the constructor returns: // error: member ‘Eigen::internal::plain_array::array’ must be initialized by mem-initializer in // ‘constexpr’ constructor -#if EIGEN_COMP_CXXVER >= 20 || defined(__clang__) +#if EIGEN_COMP_CXXVER >= 20 constexpr Matrix3i mat({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}); VERIFY_IS_EQUAL(mat.size(), 9); VERIFY_IS_EQUAL(mat(0, 0), 1); @@ -35,7 +35,7 @@ EIGEN_DECLARE_TEST(constexpr) { VERIFY_IS_EQUAL(dyn_arr(0, 0), 1); VERIFY_IS_EQUAL(dyn_arr.size(), 9); static_assert(dyn_arr.coeff(0,1) == 2); -#endif // EIGEN_COMP_CXXVER >= 20 || defined(__clang__) +#endif // EIGEN_COMP_CXXVER >= 20 } // Check that we can use the std::initializer_list constructor for constexpr variables.