1 // RUN: %clang_cc1 -std=c++98 -fcxx-exceptions -verify %s
2 // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s
3 // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
4 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s
5 // RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fsized-deallocation -verify %s
6 // RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -fsized-deallocation -verify %s
8 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
9 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -DCONCEPTS_TS=1 -verify %s
10 // RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
11 // RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
12 // RUN: %clang_cc1 -std=c++14 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
13 // RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify -fsized-deallocation %s
15 // expected-no-diagnostics
17 // FIXME using `defined` in a macro has undefined behavior.
18 #if __cplusplus < 201103L
19 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98)
20 #elif __cplusplus < 201402L
21 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11)
22 #elif __cplusplus < 201703L
23 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14)
24 #elif __cplusplus < 202002L
25 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17)
26 #elif __cplusplus == 202002L
27 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx20 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx20)
29 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx23 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx23)
32 // --- C++2b features ---
34 #if check(implicit_move, 0, 0, 0, 0, 0, 202011)
35 #error "wrong value for __cpp_implicit_move"
38 #if check(size_t_suffix, 0, 0, 0, 0, 0, 202011)
39 #error "wrong value for __cpp_size_t_suffix"
42 // --- C++20 features ---
44 #if check(aggregate_paren_init, 0, 0, 0, 0, 0, 0)
45 // FIXME: 201902 in C++20
46 #error "wrong value for __cpp_aggregate_paren_init"
49 #if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811, 201811) : \
50 defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0, 0) : \
51 check(char8_t, 0, 0, 0, 0, 201811, 201811)
52 #error "wrong value for __cpp_char8_t"
55 #if check(concepts, 0, 0, 0, 0, 201907, 201907)
56 #error "wrong value for __cpp_concepts"
59 #if check(conditional_explicit, 0, 0, 0, 0, 201806, 201806)
60 #error "wrong value for __cpp_conditional_explicit"
63 #if check(consteval, 0, 0, 0, 0, 0, 0)
64 // FIXME: 201811 in C++20
65 #error "wrong value for __cpp_consteval"
68 // constexpr checked below
70 #if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907, 201907)
71 #error "wrong value for __cpp_constexpr_dynamic_alloc"
74 #if check(constexpr_in_decltype, 0, 201711, 201711, 201711, 201711, 201711)
75 #error "wrong value for __cpp_constexpr_in_decltype"
78 #if check(constinit, 0, 0, 0, 0, 201907, 201907)
79 #error "wrong value for __cpp_constinit"
82 // deduction_guides checked below
84 #if check(designated_initializers, 0, 0, 0, 0, 201707, 201707)
85 #error "wrong value for __cpp_designated_initializers"
88 // generic_lambdas checked below
90 #if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806, 201806)
91 #error "wrong value for __cpp_impl_destroying_delete"
94 #if check(impl_three_way_comparison, 0, 0, 0, 0, 201907, 201907)
95 #error "wrong value for __cpp_impl_three_way_comparison"
98 #if check(impl_coroutine, 0, 0, 0, 0, 201902L, 201902L)
99 #error "wrong value for __cpp_impl_coroutine"
102 // init_captures checked below
104 #if check(modules, 0, 0, 0, 0, 0, 0)
105 // FIXME: 201907 in C++20
106 #error "wrong value for __cpp_modules"
109 #if check(using_enum, 0, 0, 0, 0, 201907, 201907)
110 #error "wrong value for __cpp_using_enum"
113 // --- C++17 features ---
115 #if check(hex_float, 0, 0, 0, 201603, 201603, 201603)
116 #error "wrong value for __cpp_hex_float"
119 #if check(inline_variables, 0, 0, 0, 201606, 201606, 201606)
120 #error "wrong value for __cpp_inline_variables"
123 #if check(aligned_new, 0, 0, 0, 201606, 201606, 201606)
124 #error "wrong value for __cpp_aligned_new"
127 #if check(guaranteed_copy_elision, 0, 0, 0, 201606, 201606, 201606)
128 #error "wrong value for __cpp_guaranteed_copy_elision"
131 #if check(noexcept_function_type, 0, 0, 0, 201510, 201510, 201510)
132 #error "wrong value for __cpp_noexcept_function_type"
135 #if check(fold_expressions, 0, 0, 0, 201603, 201603, 201603)
136 #error "wrong value for __cpp_fold_expressions"
139 #if check(capture_star_this, 0, 0, 0, 201603, 201603, 201603)
140 #error "wrong value for __cpp_capture_star_this"
143 // constexpr checked below
145 #if check(if_constexpr, 0, 0, 0, 201606, 201606, 201606)
146 #error "wrong value for __cpp_if_constexpr"
149 // range_based_for checked below
151 // static_assert checked below
153 #if check(deduction_guides, 0, 0, 0, 201703, 201703, 201703)
154 // FIXME: 201907 in C++20
155 #error "wrong value for __cpp_deduction_guides"
158 #if check(nontype_template_parameter_auto, 0, 0, 0, 201606, 201606, 201606)
159 #error "wrong value for __cpp_nontype_template_parameter_auto"
162 // This is the old name (from P0096R4) for
163 // __cpp_nontype_template_parameter_auto
164 #if check(template_auto, 0, 0, 0, 201606, 201606, 201606)
165 #error "wrong value for __cpp_template_auto"
168 #if check(namespace_attributes, 0, 0, 0, 201411, 201411, 201411)
169 // FIXME: allowed without warning in C++14 and C++11
170 #error "wrong value for __cpp_namespace_attributes"
173 #if check(enumerator_attributes, 0, 0, 0, 201411, 201411, 201411)
174 // FIXME: allowed without warning in C++14 and C++11
175 #error "wrong value for __cpp_enumerator_attributes"
178 // This is an old name (from P0096R4), now removed from SD-6.
179 #if check(nested_namespace_definitions, 0, 0, 0, 201411, 201411, 201411)
180 #error "wrong value for __cpp_nested_namespace_definitions"
183 // inheriting_constructors checked below
185 #if check(variadic_using, 0, 0, 0, 201611, 201611, 201611)
186 #error "wrong value for __cpp_variadic_using"
189 #if check(aggregate_bases, 0, 0, 0, 201603, 201603, 201603)
190 #error "wrong value for __cpp_aggregate_bases"
193 #if check(structured_bindings, 0, 0, 0, 201606, 201606, 201606)
194 #error "wrong value for __cpp_structured_bindings"
197 #if check(nontype_template_args, 0, 0, 0, 201411, 201411, 201411)
198 // FIXME: 201911 in C++20
199 #error "wrong value for __cpp_nontype_template_args"
202 #if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
203 ? check(template_template_args, 0, 0, 0, 201611, 201611, 201611) \
204 : check(template_template_args, 0, 0, 0, 0, 0, 0)
205 #error "wrong value for __cpp_template_template_args"
208 // --- C++14 features ---
210 #if check(binary_literals, 0, 0, 201304, 201304, 201304, 201304)
211 #error "wrong value for __cpp_binary_literals"
214 // (Removed from SD-6.)
215 #if check(digit_separators, 0, 0, 201309, 201309, 201309, 201309)
216 #error "wrong value for __cpp_digit_separators"
219 #if check(init_captures, 0, 0, 201304, 201304, 201803, 201803)
220 #error "wrong value for __cpp_init_captures"
223 #if check(generic_lambdas, 0, 0, 201304, 201304, 201707, 201707)
224 #error "wrong value for __cpp_generic_lambdas"
227 #if check(sized_deallocation, 0, 0, 201309, 201309, 201309, 201309)
228 #error "wrong value for __cpp_sized_deallocation"
231 // constexpr checked below
233 #if check(decltype_auto, 0, 0, 201304, 201304, 201304, 201304)
234 #error "wrong value for __cpp_decltype_auto"
237 #if check(return_type_deduction, 0, 0, 201304, 201304, 201304, 201304)
238 #error "wrong value for __cpp_return_type_deduction"
241 #if check(runtime_arrays, 0, 0, 0, 0, 0, 0)
242 #error "wrong value for __cpp_runtime_arrays"
245 #if check(aggregate_nsdmi, 0, 0, 201304, 201304, 201304, 201304)
246 #error "wrong value for __cpp_aggregate_nsdmi"
249 #if check(variable_templates, 0, 0, 201304, 201304, 201304, 201304)
250 #error "wrong value for __cpp_variable_templates"
253 // --- C++11 features ---
255 #if check(unicode_characters, 0, 200704, 200704, 200704, 200704, 200704)
256 #error "wrong value for __cpp_unicode_characters"
259 #if check(raw_strings, 0, 200710, 200710, 200710, 200710, 200710)
260 #error "wrong value for __cpp_raw_strings"
263 #if check(unicode_literals, 0, 200710, 200710, 200710, 200710, 200710)
264 #error "wrong value for __cpp_unicode_literals"
267 #if check(user_defined_literals, 0, 200809, 200809, 200809, 200809, 200809)
268 #error "wrong value for __cpp_user_defined_literals"
271 #if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0, 0, 0) : \
272 check(threadsafe_static_init, 200806, 200806, 200806, 200806, 200806, 200806)
273 #error "wrong value for __cpp_threadsafe_static_init"
276 #if check(lambdas, 0, 200907, 200907, 200907, 200907, 200907)
277 #error "wrong value for __cpp_lambdas"
280 #if check(constexpr, 0, 200704, 201304, 201603, 201907, 202110)
281 #error "wrong value for __cpp_constexpr"
284 #if check(range_based_for, 0, 200907, 200907, 201603, 201603, 201603)
285 #error "wrong value for __cpp_range_based_for"
288 #if check(static_assert, 0, 200410, 200410, 201411, 201411, 201411)
289 #error "wrong value for __cpp_static_assert"
292 #if check(decltype, 0, 200707, 200707, 200707, 200707, 200707)
293 #error "wrong value for __cpp_decltype"
296 #if check(attributes, 0, 200809, 200809, 200809, 200809, 200809)
297 #error "wrong value for __cpp_attributes"
300 #if check(rvalue_references, 0, 200610, 200610, 200610, 200610, 200610)
301 #error "wrong value for __cpp_rvalue_references"
304 #if check(variadic_templates, 0, 200704, 200704, 200704, 200704, 200704)
305 #error "wrong value for __cpp_variadic_templates"
308 #if check(initializer_lists, 0, 200806, 200806, 200806, 200806, 200806)
309 #error "wrong value for __cpp_initializer_lists"
312 #if check(delegating_constructors, 0, 200604, 200604, 200604, 200604, 200604)
313 #error "wrong value for __cpp_delegating_constructors"
316 #if check(nsdmi, 0, 200809, 200809, 200809, 200809, 200809)
317 #error "wrong value for __cpp_nsdmi"
320 #if check(inheriting_constructors, 0, 201511, 201511, 201511, 201511, 201511)
321 #error "wrong value for __cpp_inheriting_constructors"
324 #if check(ref_qualifiers, 0, 200710, 200710, 200710, 200710, 200710)
325 #error "wrong value for __cpp_ref_qualifiers"
328 #if check(alias_templates, 0, 200704, 200704, 200704, 200704, 200704)
329 #error "wrong value for __cpp_alias_templates"
332 // --- C++98 features ---
334 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711, 199711, 199711)
335 #error "wrong value for __cpp_rtti"
338 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711, 199711, 199711)
339 #error "wrong value for __cpp_exceptions"
342 // --- TS features --
344 #if defined(COROUTINES) ? check(coroutines, 201703, 201703, 201703, 201703, 201703, 201703) : check(coroutines, 0, 0, 0, 0, 201703, 201703)
345 #error "wrong value for __cpp_coroutines"