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++2a -fcxx-exceptions -fsized-deallocation -verify %s
7 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
8 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
9 // RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
10 // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
11 // RUN: %clang_cc1 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
13 // expected-no-diagnostics
15 // FIXME using `defined` in a macro has undefined behavior.
16 #if __cplusplus < 201103L
17 #define check(macro, cxx98, cxx11, cxx14, cxx17) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
18 #elif __cplusplus < 201402L
19 #define check(macro, cxx98, cxx11, cxx14, cxx17) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
20 #elif __cplusplus < 201406L
21 #define check(macro, cxx98, cxx11, cxx14, cxx17) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
23 #define check(macro, cxx98, cxx11, cxx14, cxx17) cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17
26 // --- C++17 features ---
28 #if check(hex_float, 0, 0, 0, 201603)
29 #error "wrong value for __cpp_hex_float"
32 #if check(inline_variables, 0, 0, 0, 201606)
33 #error "wrong value for __cpp_inline_variables"
36 #if check(aligned_new, 0, 0, 0, 201606)
37 #error "wrong value for __cpp_aligned_new"
40 #if check(guaranteed_copy_elision, 0, 0, 0, 201606)
41 #error "wrong value for __cpp_guaranteed_copy_elision"
44 #if check(noexcept_function_type, 0, 0, 0, 201510)
45 #error "wrong value for __cpp_noexcept_function_type"
48 #if check(fold_expressions, 0, 0, 0, 201603)
49 #error "wrong value for __cpp_fold_expressions"
52 #if check(capture_star_this, 0, 0, 0, 201603)
53 #error "wrong value for __cpp_capture_star_this"
56 // constexpr checked below
58 #if check(if_constexpr, 0, 0, 0, 201606)
59 #error "wrong value for __cpp_if_constexpr"
62 // range_based_for checked below
64 // static_assert checked below
66 #if check(deduction_guides, 0, 0, 0, 201703)
67 #error "wrong value for __cpp_deduction_guides"
70 #if check(nontype_template_parameter_auto, 0, 0, 0, 201606)
71 #error "wrong value for __cpp_nontype_template_parameter_auto"
74 // This is the old name (from P0096R4) for
75 // __cpp_nontype_template_parameter_auto
76 #if check(template_auto, 0, 0, 0, 201606)
77 #error "wrong value for __cpp_template_auto"
80 #if check(namespace_attributes, 0, 0, 0, 201411)
81 // FIXME: allowed without warning in C++14 and C++11
82 #error "wrong value for __cpp_namespace_attributes"
85 #if check(enumerator_attributes, 0, 0, 0, 201411)
86 // FIXME: allowed without warning in C++14 and C++11
87 #error "wrong value for __cpp_enumerator_attributes"
90 // This is an old name (from P0096R4), now removed from SD-6.
91 #if check(nested_namespace_definitions, 0, 0, 0, 201411)
92 #error "wrong value for __cpp_nested_namespace_definitions"
95 // inheriting_constructors checked below
97 #if check(variadic_using, 0, 0, 0, 201611)
98 #error "wrong value for __cpp_variadic_using"
101 #if check(aggregate_bases, 0, 0, 0, 201603)
102 #error "wrong value for __cpp_aggregate_bases"
105 #if check(structured_bindings, 0, 0, 0, 201606)
106 #error "wrong value for __cpp_structured_bindings"
109 #if check(nontype_template_args, 0, 0, 0, 201411)
110 #error "wrong value for __cpp_nontype_template_args"
113 #if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
114 ? check(template_template_args, 0, 0, 0, 201611) \
115 : check(template_template_args, 0, 0, 0, 0)
116 #error "wrong value for __cpp_template_template_args"
119 // --- C++14 features ---
121 #if check(binary_literals, 0, 0, 201304, 201304)
122 #error "wrong value for __cpp_binary_literals"
125 // (Removed from SD-6.)
126 #if check(digit_separators, 0, 0, 201309, 201309)
127 #error "wrong value for __cpp_digit_separators"
130 #if check(init_captures, 0, 0, 201304, 201304)
131 #error "wrong value for __cpp_init_captures"
134 #if check(generic_lambdas, 0, 0, 201304, 201304)
135 #error "wrong value for __cpp_generic_lambdas"
138 #if check(sized_deallocation, 0, 0, 201309, 201309)
139 #error "wrong value for __cpp_sized_deallocation"
142 // constexpr checked below
144 #if check(decltype_auto, 0, 0, 201304, 201304)
145 #error "wrong value for __cpp_decltype_auto"
148 #if check(return_type_deduction, 0, 0, 201304, 201304)
149 #error "wrong value for __cpp_return_type_deduction"
152 #if check(runtime_arrays, 0, 0, 0, 0)
153 #error "wrong value for __cpp_runtime_arrays"
156 #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
157 #error "wrong value for __cpp_aggregate_nsdmi"
160 #if check(variable_templates, 0, 0, 201304, 201304)
161 #error "wrong value for __cpp_variable_templates"
164 // --- C++11 features ---
166 #if check(unicode_characters, 0, 200704, 200704, 200704)
167 #error "wrong value for __cpp_unicode_characters"
170 #if check(raw_strings, 0, 200710, 200710, 200710)
171 #error "wrong value for __cpp_raw_strings"
174 #if check(unicode_literals, 0, 200710, 200710, 200710)
175 #error "wrong value for __cpp_unicode_literals"
178 #if check(user_defined_literals, 0, 200809, 200809, 200809)
179 #error "wrong value for __cpp_user_defined_literals"
182 #if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0) : check(threadsafe_static_init, 200806, 200806, 200806, 200806)
183 #error "wrong value for __cpp_threadsafe_static_init"
186 #if check(lambdas, 0, 200907, 200907, 200907)
187 #error "wrong value for __cpp_lambdas"
190 #if check(constexpr, 0, 200704, 201304, 201603)
191 #error "wrong value for __cpp_constexpr"
194 #if check(range_based_for, 0, 200907, 200907, 201603)
195 #error "wrong value for __cpp_range_based_for"
198 #if check(static_assert, 0, 200410, 200410, 201411)
199 #error "wrong value for __cpp_static_assert"
202 #if check(decltype, 0, 200707, 200707, 200707)
203 #error "wrong value for __cpp_decltype"
206 #if check(attributes, 0, 200809, 200809, 200809)
207 #error "wrong value for __cpp_attributes"
210 #if check(rvalue_references, 0, 200610, 200610, 200610)
211 #error "wrong value for __cpp_rvalue_references"
214 #if check(variadic_templates, 0, 200704, 200704, 200704)
215 #error "wrong value for __cpp_variadic_templates"
218 #if check(initializer_lists, 0, 200806, 200806, 200806)
219 #error "wrong value for __cpp_initializer_lists"
222 #if check(delegating_constructors, 0, 200604, 200604, 200604)
223 #error "wrong value for __cpp_delegating_constructors"
226 #if check(nsdmi, 0, 200809, 200809, 200809)
227 #error "wrong value for __cpp_nsdmi"
230 #if check(inheriting_constructors, 0, 201511, 201511, 201511)
231 #error "wrong value for __cpp_inheriting_constructors"
234 #if check(ref_qualifiers, 0, 200710, 200710, 200710)
235 #error "wrong value for __cpp_ref_qualifiers"
238 #if check(alias_templates, 0, 200704, 200704, 200704)
239 #error "wrong value for __cpp_alias_templates"
242 // --- C++98 features ---
244 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
245 #error "wrong value for __cpp_rtti"
248 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
249 #error "wrong value for __cpp_exceptions"
252 // --- TS features --
254 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
255 #error "wrong value for __cpp_experimental_concepts"
258 #if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0)
259 #error "wrong value for __cpp_coroutines"
262 // --- not-yet-standard features --
264 #if defined(CHAR8_T) ? check(char8_t, 201803, 201803, 201803, 201803) : check(char8_t, 0, 0, 0, 0)
265 #error "wrong value for __cpp_char8_t"