Skip to content

Commit 8f018d3

Browse files
[libc++][test] Make the feature-test macro tests more portable (#74185)
Found while running libc++'s test suite with MSVC's STL. This is a followup to @philnik777's recent #71002 (thank you!) which provided the existing examples of `__cpp_lib_barrier` and `__cpp_lib_polymorphic_allocator`: https://github.com/llvm/llvm-project/blob/66a3e4fafb6eae19764f8a192ca3a116c0554211/libcxx/utils/generate_feature_test_macro_components.py#L199-L203 https://github.com/llvm/llvm-project/blob/66a3e4fafb6eae19764f8a192ca3a116c0554211/libcxx/utils/generate_feature_test_macro_components.py#L866-L870 Applying that new pattern to the feature-test macros here gets their corresponding tests passing for us. :robot: Only `generate_feature_test_macro_components.py` was manually updated; the other files were regenerated.
1 parent 091a9f4 commit 8f018d3

7 files changed

+62
-62
lines changed

libcxx/test/std/language.support/support.limits/support.limits.general/latch.version.compile.pass.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#elif TEST_STD_VER == 20
4646

47-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
47+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
4848
# ifndef __cpp_lib_latch
4949
# error "__cpp_lib_latch should be defined in c++20"
5050
# endif
@@ -53,13 +53,13 @@
5353
# endif
5454
# else
5555
# ifdef __cpp_lib_latch
56-
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
56+
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
5757
# endif
5858
# endif
5959

6060
#elif TEST_STD_VER == 23
6161

62-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
62+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
6363
# ifndef __cpp_lib_latch
6464
# error "__cpp_lib_latch should be defined in c++23"
6565
# endif
@@ -68,13 +68,13 @@
6868
# endif
6969
# else
7070
# ifdef __cpp_lib_latch
71-
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
71+
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
7272
# endif
7373
# endif
7474

7575
#elif TEST_STD_VER > 23
7676

77-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
77+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
7878
# ifndef __cpp_lib_latch
7979
# error "__cpp_lib_latch should be defined in c++26"
8080
# endif
@@ -83,7 +83,7 @@
8383
# endif
8484
# else
8585
# ifdef __cpp_lib_latch
86-
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
86+
# error "__cpp_lib_latch should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
8787
# endif
8888
# endif
8989

libcxx/test/std/language.support/support.limits/support.limits.general/new.version.compile.pass.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# error "__cpp_lib_destroying_delete should not be defined before c++20"
5959
# endif
6060

61-
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
61+
# if !defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))
6262
# ifndef __cpp_lib_hardware_interference_size
6363
# error "__cpp_lib_hardware_interference_size should be defined in c++17"
6464
# endif
@@ -67,7 +67,7 @@
6767
# endif
6868
# else
6969
# ifdef __cpp_lib_hardware_interference_size
70-
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement 'defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)' is not met!"
70+
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement '!defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))' is not met!"
7171
# endif
7272
# endif
7373

@@ -93,7 +93,7 @@
9393
# endif
9494
# endif
9595

96-
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
96+
# if !defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))
9797
# ifndef __cpp_lib_hardware_interference_size
9898
# error "__cpp_lib_hardware_interference_size should be defined in c++20"
9999
# endif
@@ -102,7 +102,7 @@
102102
# endif
103103
# else
104104
# ifdef __cpp_lib_hardware_interference_size
105-
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement 'defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)' is not met!"
105+
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement '!defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))' is not met!"
106106
# endif
107107
# endif
108108

@@ -128,7 +128,7 @@
128128
# endif
129129
# endif
130130

131-
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
131+
# if !defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))
132132
# ifndef __cpp_lib_hardware_interference_size
133133
# error "__cpp_lib_hardware_interference_size should be defined in c++23"
134134
# endif
@@ -137,7 +137,7 @@
137137
# endif
138138
# else
139139
# ifdef __cpp_lib_hardware_interference_size
140-
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement 'defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)' is not met!"
140+
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement '!defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))' is not met!"
141141
# endif
142142
# endif
143143

@@ -163,7 +163,7 @@
163163
# endif
164164
# endif
165165

166-
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
166+
# if !defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))
167167
# ifndef __cpp_lib_hardware_interference_size
168168
# error "__cpp_lib_hardware_interference_size should be defined in c++26"
169169
# endif
@@ -172,7 +172,7 @@
172172
# endif
173173
# else
174174
# ifdef __cpp_lib_hardware_interference_size
175-
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement 'defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)' is not met!"
175+
# error "__cpp_lib_hardware_interference_size should not be defined when the requirement '!defined(_LIBCPP_VERSION) || (defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE))' is not met!"
176176
# endif
177177
# endif
178178

libcxx/test/std/language.support/support.limits/support.limits.general/semaphore.version.compile.pass.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#elif TEST_STD_VER == 20
4646

47-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
47+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
4848
# ifndef __cpp_lib_semaphore
4949
# error "__cpp_lib_semaphore should be defined in c++20"
5050
# endif
@@ -53,13 +53,13 @@
5353
# endif
5454
# else
5555
# ifdef __cpp_lib_semaphore
56-
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
56+
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
5757
# endif
5858
# endif
5959

6060
#elif TEST_STD_VER == 23
6161

62-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
62+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
6363
# ifndef __cpp_lib_semaphore
6464
# error "__cpp_lib_semaphore should be defined in c++23"
6565
# endif
@@ -68,13 +68,13 @@
6868
# endif
6969
# else
7070
# ifdef __cpp_lib_semaphore
71-
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
71+
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
7272
# endif
7373
# endif
7474

7575
#elif TEST_STD_VER > 23
7676

77-
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC
77+
# if !defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
7878
# ifndef __cpp_lib_semaphore
7979
# error "__cpp_lib_semaphore should be defined in c++26"
8080
# endif
@@ -83,7 +83,7 @@
8383
# endif
8484
# else
8585
# ifdef __cpp_lib_semaphore
86-
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
86+
# error "__cpp_lib_semaphore should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
8787
# endif
8888
# endif
8989

libcxx/test/std/language.support/support.limits/support.limits.general/stop_token.version.compile.pass.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#elif TEST_STD_VER == 20
4646

47-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
47+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
4848
# ifndef __cpp_lib_jthread
4949
# error "__cpp_lib_jthread should be defined in c++20"
5050
# endif
@@ -53,13 +53,13 @@
5353
# endif
5454
# else
5555
# ifdef __cpp_lib_jthread
56-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
56+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
5757
# endif
5858
# endif
5959

6060
#elif TEST_STD_VER == 23
6161

62-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
62+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
6363
# ifndef __cpp_lib_jthread
6464
# error "__cpp_lib_jthread should be defined in c++23"
6565
# endif
@@ -68,13 +68,13 @@
6868
# endif
6969
# else
7070
# ifdef __cpp_lib_jthread
71-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
71+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
7272
# endif
7373
# endif
7474

7575
#elif TEST_STD_VER > 23
7676

77-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
77+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
7878
# ifndef __cpp_lib_jthread
7979
# error "__cpp_lib_jthread should be defined in c++26"
8080
# endif
@@ -83,7 +83,7 @@
8383
# endif
8484
# else
8585
# ifdef __cpp_lib_jthread
86-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
86+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
8787
# endif
8888
# endif
8989

libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# error "__cpp_lib_formatters should not be defined before c++23"
6262
# endif
6363

64-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
64+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
6565
# ifndef __cpp_lib_jthread
6666
# error "__cpp_lib_jthread should be defined in c++20"
6767
# endif
@@ -70,7 +70,7 @@
7070
# endif
7171
# else
7272
# ifdef __cpp_lib_jthread
73-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
73+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
7474
# endif
7575
# endif
7676

@@ -89,7 +89,7 @@
8989
# endif
9090
# endif
9191

92-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
92+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
9393
# ifndef __cpp_lib_jthread
9494
# error "__cpp_lib_jthread should be defined in c++23"
9595
# endif
@@ -98,7 +98,7 @@
9898
# endif
9999
# else
100100
# ifdef __cpp_lib_jthread
101-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
101+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
102102
# endif
103103
# endif
104104

@@ -117,7 +117,7 @@
117117
# endif
118118
# endif
119119

120-
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC
120+
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
121121
# ifndef __cpp_lib_jthread
122122
# error "__cpp_lib_jthread should be defined in c++26"
123123
# endif
@@ -126,7 +126,7 @@
126126
# endif
127127
# else
128128
# ifdef __cpp_lib_jthread
129-
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC' is not met!"
129+
# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
130130
# endif
131131
# endif
132132

0 commit comments

Comments
 (0)