@@ -27,36 +27,7 @@ add_fail_tests(
2727 template_for_each_not_list
2828 to_address_undefined_on_function)
2929
30- function (add_formatted_error_tests)
31- add_fail_tests(ct_check)
32- add_fail_tests(static_assert)
33- add_fail_tests(static_assert_format)
34- endfunction ()
35-
36- function (add_26_formatted_error_tests)
37- add_compile_fail_test("static_assert.cpp" NAME static_assert_26 LIBRARIES
38- stdx)
39- add_compile_fail_test("static_assert_format.cpp" NAME
40- static_assert_format_26 LIBRARIES stdx)
41- target_compile_features (EXPECT_FAIL.static_assert_26 PRIVATE cxx_std_26)
42- target_compile_features (EXPECT_FAIL.static_assert_format_26
43- PRIVATE cxx_std_26)
44- endfunction ()
45-
4630if (${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
47- if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"
48- AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 15)
49- add_formatted_error_tests()
50- endif ()
51- if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION}
52- VERSION_GREATER_EQUAL 13.2)
53- add_formatted_error_tests()
54- endif ()
55-
56- if ("cxx_std_26" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
57- add_26_formatted_error_tests()
58- endif ()
59-
6031 add_fail_tests(
6132 atomic_bool_dec
6233 ct_format_mismatch
@@ -69,3 +40,32 @@ if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
6940 tuple_spaceship_with_element
7041 tuple_type_not_found)
7142endif ()
43+
44+ function (add_test_by_compiler CPP_NAME CXX_VERSION COMPILER_ID COMPILER_VERSION)
45+ if ("cxx_std_${CXX_VERSION} " IN_LIST CMAKE_CXX_COMPILE_FEATURES)
46+ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "${COMPILER_ID} "
47+ AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL
48+ ${COMPILER_VERSION} )
49+ set (TEST_NAME "${CPP_NAME} _${COMPILER_ID} _${COMPILER_VERSION} " )
50+ add_compile_fail_test("${CPP_NAME} .cpp" NAME ${TEST_NAME} LIBRARIES
51+ stdx)
52+ target_compile_features ("EXPECT_FAIL.${TEST_NAME} "
53+ PRIVATE "cxx_std_${CXX_VERSION} " )
54+ endif ()
55+ endif ()
56+ endfunction ()
57+
58+ add_test_by_compiler(ct_check 20 Clang 15)
59+ add_test_by_compiler(ct_check 20 GNU 13.2)
60+ add_test_by_compiler(static_assert 20 Clang 15)
61+ add_test_by_compiler(static_assert 20 GNU 13.2)
62+ add_test_by_compiler(static_assert_format 20 Clang 15)
63+ add_test_by_compiler(static_assert_format 20 GNU 13.2)
64+
65+ add_test_by_compiler(static_assert 26 Clang 17)
66+ add_test_by_compiler(static_assert 26 GNU 14)
67+ add_test_by_compiler(static_assert_format 26 Clang 17)
68+ add_test_by_compiler(static_assert_format 26 GNU 14)
69+
70+ add_test_by_compiler(rollover_less_than_26 26 Clang 19)
71+ add_test_by_compiler(rollover_less_than_26 26 GNU 15)
0 commit comments