diff --git a/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp b/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp --- a/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp +++ b/libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp @@ -13,6 +13,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" template @@ -139,7 +140,7 @@ #endif (void)std::is_sorted(first, last, Less(&copies)); assert(copies == 0); (void)std::is_sorted_until(first, last, Less(&copies)); assert(copies == 0); - if (!TEST_IS_CONSTANT_EVALUATED) { (void)std::inplace_merge(first, mid, last, Less(&copies)); assert(copies == 0); } + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { (void)std::inplace_merge(first, mid, last, Less(&copies)); assert(copies == 0); } (void)std::lexicographical_compare(first, last, first2, last2, Less(&copies)); assert(copies == 0); #if TEST_STD_VER > 17 //(void)std::lexicographical_compare_three_way(first, last, first2, last2, ThreeWay(&copies)); assert(copies == 0); @@ -194,8 +195,8 @@ (void)std::sort(first, first+5, Less(&copies)); assert(copies == 0); (void)std::sort(first, last, Less(&copies)); assert(copies == 0); (void)std::sort_heap(first, last, Less(&copies)); assert(copies == 0); - if (!TEST_IS_CONSTANT_EVALUATED) { (void)std::stable_partition(first, last, UnaryTrue(&copies)); assert(copies == 0); } - if (!TEST_IS_CONSTANT_EVALUATED) { (void)std::stable_sort(first, last, Less(&copies)); assert(copies == 0); } + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { (void)std::stable_partition(first, last, UnaryTrue(&copies)); assert(copies == 0); } + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { (void)std::stable_sort(first, last, Less(&copies)); assert(copies == 0); } (void)std::transform(first, last, first2, UnaryTransform(&copies)); assert(copies == 0); (void)std::transform(first, mid, mid, first2, BinaryTransform(&copies)); assert(copies == 0); (void)std::unique(first, last, Equal(&copies)); assert(copies == 0); diff --git a/libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp b/libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp --- a/libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp +++ b/libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" // This iterator rejects expressions like (a + n) and (a - n) @@ -140,8 +141,8 @@ (void)std::is_sorted(first, last, std::less()); (void)std::is_sorted_until(first, last); (void)std::is_sorted_until(first, last, std::less()); - if (!TEST_IS_CONSTANT_EVALUATED) (void)std::inplace_merge(first, mid, last); - if (!TEST_IS_CONSTANT_EVALUATED) (void)std::inplace_merge(first, mid, last, std::less()); + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) (void)std::inplace_merge(first, mid, last); + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) (void)std::inplace_merge(first, mid, last, std::less()); (void)std::iter_swap(first, mid); (void)std::lexicographical_compare(first, last, first2, last2); (void)std::lexicographical_compare(first, last, first2, last2, std::less()); @@ -234,9 +235,9 @@ (void)std::sort(first, last, std::less()); (void)std::sort_heap(first, last); (void)std::sort_heap(first, last, std::less()); - if (!TEST_IS_CONSTANT_EVALUATED) (void)std::stable_partition(first, last, UnaryTrue()); - if (!TEST_IS_CONSTANT_EVALUATED) (void)std::stable_sort(first, last); - if (!TEST_IS_CONSTANT_EVALUATED) (void)std::stable_sort(first, last, std::less()); + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) (void)std::stable_partition(first, last, UnaryTrue()); + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) (void)std::stable_sort(first, last); + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) (void)std::stable_sort(first, last, std::less()); (void)std::swap_ranges(first, last, first2); (void)std::transform(first, last, first2, UnaryTransform()); (void)std::transform(first, mid, mid, first2, BinaryTransform()); diff --git a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp @@ -17,6 +17,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" template @@ -30,7 +31,7 @@ assert(cs.at(pos) == cs[pos]); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -46,7 +47,7 @@ #endif } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -28,7 +29,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -28,7 +29,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -43,7 +44,7 @@ assert(s2.capacity() >= s2.size()); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -76,7 +77,7 @@ assert(s2.capacity() >= s2.size()); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp @@ -13,6 +13,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -106,7 +107,7 @@ } #ifndef TEST_HAS_NO_EXCEPTIONS - if (!TEST_IS_CONSTANT_EVALUATED) { + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { typedef poca_alloc A; typedef std::basic_string, A> S; const char * p1 = "This is my first string"; diff --git a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -23,6 +23,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -45,7 +46,7 @@ assert(s2.capacity() >= s2.size()); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -77,7 +78,7 @@ assert(s2.capacity() >= s2.size()); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -109,7 +110,7 @@ assert(s2.capacity() >= s2.size()); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -30,7 +31,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -56,7 +57,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -172,7 +173,7 @@ } #endif #ifndef TEST_HAS_NO_EXCEPTIONS - if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { // test iterator operations that throw typedef std::string S; typedef ThrowingIterator TIter; typedef cpp17_input_iterator IIter; @@ -229,7 +230,7 @@ s_sneaky.reserve(12); test(s_sneaky, s_sneaky.data(), s_sneaky.data() + 6, std::string("hellohello\0", 11)); - if (!TEST_IS_CONSTANT_EVALUATED) { + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { const unsigned char *first = reinterpret_cast(s_othertype.data()); test(s_othertype, first + 2, first + 5, std::string("hellollo")); } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -30,7 +31,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -56,7 +57,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -29,7 +30,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -55,7 +56,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -172,7 +173,7 @@ } #endif #ifndef TEST_HAS_NO_EXCEPTIONS - if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { // test iterator operations that throw typedef std::string S; typedef ThrowingIterator TIter; typedef cpp17_input_iterator IIter; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -30,7 +31,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -56,7 +57,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -33,7 +34,7 @@ assert(S::traits_type::eq(cs[pos+r], s[r])); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -32,7 +33,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -62,7 +63,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -150,7 +151,7 @@ } #endif #ifndef TEST_HAS_NO_EXCEPTIONS - if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { // test iterator operations that throw typedef std::string S; typedef ThrowingIterator TIter; typedef cpp17_input_iterator IIter; @@ -193,7 +194,7 @@ assert(s == "ABCD"); } - if (!TEST_IS_CONSTANT_EVALUATED) { // regression-test inserting into self in sneaky ways + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { // regression-test inserting into self in sneaky ways std::string s_short = "hello"; std::string s_long = "Lorem ipsum dolor sit amet, consectetur/"; std::string s_othertype = "hello"; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -35,7 +36,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -65,7 +66,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -31,7 +32,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -32,7 +33,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -32,7 +33,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -31,7 +32,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -34,7 +35,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -63,7 +64,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -31,7 +32,7 @@ assert(s == expected); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" #include "test_iterators.h" @@ -995,7 +996,7 @@ template TEST_CONSTEXPR_CXX20 bool test9() { #ifndef TEST_HAS_NO_EXCEPTIONS - if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { // test iterator operations that throw typedef ThrowingIterator TIter; typedef cpp17_input_iterator IIter; const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -47,7 +48,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -83,7 +84,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -36,7 +37,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -37,7 +38,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -37,7 +38,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -35,7 +36,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -39,7 +40,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -73,7 +74,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -35,7 +36,7 @@ assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp @@ -20,6 +20,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" TEST_CONSTEXPR_CXX20 int sign(int x) @@ -40,7 +41,7 @@ if (pos1 <= s.size() && pos2 <= sv.size()) assert(sign(s.compare(pos1, n1, sv, pos2, n2)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -64,7 +65,7 @@ if (pos1 <= s.size() && pos2 <= sv.size()) assert(sign(s.compare(pos1, n1, sv, pos2)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp @@ -16,6 +16,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" TEST_CONSTEXPR_CXX20 int sign(int x) @@ -35,7 +36,7 @@ if (pos1 <= s.size()) assert(sign(s.compare(pos1, n1, str)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp @@ -16,6 +16,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" TEST_CONSTEXPR_CXX20 int sign(int x) @@ -35,7 +36,7 @@ if (pos <= s.size()) assert(sign(s.compare(pos, n1, str, n2)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -34,7 +35,7 @@ if (pos1 <= s.size()) assert(sign(s.compare(pos1, n1, str)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp @@ -18,6 +18,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" TEST_CONSTEXPR_CXX20 int sign(int x) @@ -37,7 +38,7 @@ if (pos1 <= s.size() && pos2 <= str.size()) assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { @@ -60,7 +61,7 @@ if (pos1 <= s.size() && pos2 <= str.size()) assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp @@ -16,6 +16,7 @@ #include "min_allocator.h" +#include "constant_evaluated.h" #include "test_macros.h" TEST_CONSTEXPR_CXX20 int sign(int x) @@ -35,7 +36,7 @@ if (pos1 <= s.size()) assert(sign(s.compare(pos1, n1, sv)) == sign(x)); #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "min_allocator.h" @@ -32,7 +33,7 @@ assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0); } #ifndef TEST_HAS_NO_EXCEPTIONS - else if (!TEST_IS_CONSTANT_EVALUATED) + else if (!is_constant_evaluated(TestedCppVersion::Cpp20)) { try { diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,7 @@ assert((ConvertibleTo(v[i]) == v[j]) == expected); assert((v[i] == ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) == v[j]) == expected); assert((v[i] == std::basic_string(v[j])) == expected); } @@ -75,7 +76,7 @@ assert((abc.data() == abc0def) == false); assert((abc0def == abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) == abc0def) == false); assert((abc0def == std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,7 @@ assert((ConvertibleTo(v[i]) > v[j]) == expected); assert((v[i] > ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) > v[j]) == expected); assert((v[i] > std::basic_string(v[j])) == expected); } @@ -75,7 +76,7 @@ assert((abc.data() > abc0def) == false); assert((abc0def > abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) > abc0def) == false); assert((abc0def > std::basic_string(abc)) == true); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,7 @@ assert((ConvertibleTo(v[i]) >= v[j]) == expected); assert((v[i] >= ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) >= v[j]) == expected); assert((v[i] >= std::basic_string(v[j])) == expected); } @@ -75,7 +76,7 @@ assert((abc.data() >= abc0def) == false); assert((abc0def >= abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) >= abc0def) == false); assert((abc0def >= std::basic_string(abc)) == true); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,7 @@ assert((ConvertibleTo(v[i]) < v[j]) == expected); assert((v[i] < ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) < v[j]) == expected); assert((v[i] < std::basic_string(v[j])) == expected); } @@ -75,7 +76,7 @@ assert((abc.data() < abc0def) == true); assert((abc0def < abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) < abc0def) == true); assert((abc0def < std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,7 @@ assert((ConvertibleTo(v[i]) <= v[j]) == expected); assert((v[i] <= ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) <= v[j]) == expected); assert((v[i] <= std::basic_string(v[j])) == expected); } @@ -75,7 +76,7 @@ assert((abc.data() <= abc0def) == true); assert((abc0def <= abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) <= abc0def) == true); assert((abc0def <= std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" #include "constexpr_char_traits.h" #include "make_string.h" @@ -54,7 +55,8 @@ assert((ConvertibleTo(v[i]) != v[j]) == expected); assert((v[i] != ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + // fails in C++17 + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(v[i]) != v[j]) == expected); assert((v[i] != std::basic_string(v[j])) == expected); } @@ -75,7 +77,7 @@ assert((abc.data() != abc0def) == true); assert((abc0def != abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (!is_constant_evaluated(TestedCppVersion::Cpp14) || TEST_STD_VER >= 20) { assert((std::basic_string(abc) != abc0def) == true); assert((abc0def != std::basic_string(abc)) == true); } diff --git a/libcxx/test/support/constant_evaluated.h b/libcxx/test/support/constant_evaluated.h new file mode 100644 --- /dev/null +++ b/libcxx/test/support/constant_evaluated.h @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_SUPPORT_CONSTANT_EVALUATED_H +#define TEST_SUPPORT_CONSTANT_EVALUATED_H + +#include +#include + +#include "test_macros.h" + +enum class TestedCppVersion { + Cpp14, + Cpp17, + Cpp20, + Cpp23, +}; + +TEST_CONSTEXPR_CXX14 bool is_constant_evaluated([[maybe_unused]] TestedCppVersion version) { +#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L +# define IS_CONSTANT_EVALUATED std::is_constant_evaluated() +#elif TEST_HAS_BUILTIN(__builtin_is_constant_evaluated) +# define IS_CONSTANT_EVALUATED __builtin_is_constant_evaluated() +#endif + +#ifndef IS_CONSTANT_EVALUATED + return false; +#else + + switch (version) { + case TestedCppVersion::Cpp14: + return IS_CONSTANT_EVALUATED && TEST_STD_VER > 11; + case TestedCppVersion::Cpp17: + return IS_CONSTANT_EVALUATED && TEST_STD_VER > 14; + case TestedCppVersion::Cpp20: + return IS_CONSTANT_EVALUATED && TEST_STD_VER > 17; + case TestedCppVersion::Cpp23: + return IS_CONSTANT_EVALUATED && TEST_STD_VER > 20; + } + assert(false); +# undef IS_CONSTANT_EVALUATED +#endif +} + +#endif // TEST_SUPPORT_CONSTANT_EVALUATED_H diff --git a/libcxx/test/support/constexpr_char_traits.h b/libcxx/test/support/constexpr_char_traits.h --- a/libcxx/test/support/constexpr_char_traits.h +++ b/libcxx/test/support/constexpr_char_traits.h @@ -13,6 +13,7 @@ #include #include +#include "constant_evaluated.h" #include "test_macros.h" template @@ -118,7 +119,7 @@ TEST_CONSTEXPR_CXX14 _CharT* constexpr_char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { - if (!TEST_IS_CONSTANT_EVALUATED) // fails in constexpr because we might be comparing unrelated pointers + if (!is_constant_evaluated(TestedCppVersion::Cpp20)) // fails in constexpr because we might be comparing unrelated pointers assert(__s2 < __s1 || __s2 >= __s1+__n); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -140,14 +140,6 @@ # define TEST_THROW_SPEC(...) throw(__VA_ARGS__) #endif -#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L -# define TEST_IS_CONSTANT_EVALUATED std::is_constant_evaluated() -#elif TEST_HAS_BUILTIN(__builtin_is_constant_evaluated) -# define TEST_IS_CONSTANT_EVALUATED __builtin_is_constant_evaluated() -#else -# define TEST_IS_CONSTANT_EVALUATED false -#endif - #if TEST_STD_VER >= 14 # define TEST_CONSTEXPR_CXX14 constexpr #else