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++1y -fcxx-exceptions -fsized-deallocation -verify %s
4 // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
5 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -verify %s
6 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
7 // RUN: %clang_cc1 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
8 // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s
10 // expected-no-diagnostics
12 // FIXME using `defined` in a macro has undefined behavior.
13 #if __cplusplus < 201103L
14 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
15 #elif __cplusplus < 201402L
16 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
17 #elif __cplusplus < 201406L
18 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
20 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
23 // --- C++17 features ---
25 #if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
26 #error "wrong value for __cpp_variadic_using"
29 #if check(hex_float, 0, 0, 0, 201603)
30 #error "wrong value for __cpp_hex_float"
33 #if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name
34 #error "wrong value for __cpp_inline_variables"
37 #if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name
38 #error "wrong value for __cpp_aligned_new"
41 #if check(noexcept_function_type, 0, 0, 0, 201510)
42 #error "wrong value for __cpp_noexcept_function_type"
45 #if check(fold_expressions, 0, 0, 0, 201603)
46 #error "wrong value for __cpp_fold_expressions"
49 #if check(capture_star_this, 0, 0, 0, 201603)
50 #error "wrong value for __cpp_capture_star_this"
53 // FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support
55 #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
56 #error "wrong value for __cpp_if_constexpr"
59 // range_based_for checked below
61 // static_assert checked below
63 #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
64 #error "wrong value for __cpp_template_auto"
67 #if check(namespace_attributes, 0, 0, 0, 201411)
68 // FIXME: allowed without warning in C++14 and C++11
69 #error "wrong value for __cpp_namespace_attributes"
72 #if check(enumerator_attributes, 0, 0, 0, 201411)
73 // FIXME: allowed without warning in C++14 and C++11
74 #error "wrong value for __cpp_enumerator_attributes"
77 #if check(nested_namespace_definitions, 0, 0, 0, 201411)
78 #error "wrong value for __cpp_nested_namespace_definitions"
81 // inheriting_constructors checked below
83 #if check(aggregate_bases, 0, 0, 0, 201603)
84 #error "wrong value for __cpp_aggregate_bases"
87 #if check(structured_bindings, 0, 0, 0, 201606)
88 #error "wrong value for __cpp_structured_bindings"
91 #if check(nontype_template_args, 0, 0, 0, 201411)
92 #error "wrong value for __cpp_nontype_template_args"
95 // --- C++14 features ---
97 #if check(binary_literals, 0, 0, 201304, 201304)
98 #error "wrong value for __cpp_binary_literals"
101 // (Removed from SD-6.)
102 #if check(digit_separators, 0, 0, 201309, 201309)
103 #error "wrong value for __cpp_digit_separators"
106 #if check(init_captures, 0, 0, 201304, 201304)
107 #error "wrong value for __cpp_init_captures"
110 #if check(generic_lambdas, 0, 0, 201304, 201304)
111 #error "wrong value for __cpp_generic_lambdas"
114 #if check(sized_deallocation, 0, 0, 201309, 201309)
115 #error "wrong value for __cpp_sized_deallocation"
118 // constexpr checked below
120 #if check(decltype_auto, 0, 0, 201304, 201304)
121 #error "wrong value for __cpp_decltype_auto"
124 #if check(return_type_deduction, 0, 0, 201304, 201304)
125 #error "wrong value for __cpp_return_type_deduction"
128 #if check(runtime_arrays, 0, 0, 0, 0)
129 #error "wrong value for __cpp_runtime_arrays"
132 #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
133 #error "wrong value for __cpp_aggregate_nsdmi"
136 #if check(variable_templates, 0, 0, 201304, 201304)
137 #error "wrong value for __cpp_variable_templates"
140 // --- C++11 features ---
142 #if check(unicode_characters, 0, 200704, 200704, 200704)
143 #error "wrong value for __cpp_unicode_characters"
146 #if check(raw_strings, 0, 200710, 200710, 200710)
147 #error "wrong value for __cpp_raw_strings"
150 #if check(unicode_literals, 0, 200710, 200710, 200710)
151 #error "wrong value for __cpp_unicode_literals"
154 #if check(user_defined_literals, 0, 200809, 200809, 200809)
155 #error "wrong value for __cpp_user_defined_literals"
158 #if check(lambdas, 0, 200907, 200907, 200907)
159 #error "wrong value for __cpp_lambdas"
162 #if check(constexpr, 0, 200704, 201304, 201304)
163 #error "wrong value for __cpp_constexpr"
166 #if check(range_based_for, 0, 200907, 200907, 201603)
167 #error "wrong value for __cpp_range_based_for"
170 #if check(static_assert, 0, 200410, 200410, 201411)
171 #error "wrong value for __cpp_static_assert"
174 #if check(decltype, 0, 200707, 200707, 200707)
175 #error "wrong value for __cpp_decltype"
178 #if check(attributes, 0, 200809, 200809, 200809)
179 #error "wrong value for __cpp_attributes"
182 #if check(rvalue_references, 0, 200610, 200610, 200610)
183 #error "wrong value for __cpp_rvalue_references"
186 #if check(variadic_templates, 0, 200704, 200704, 200704)
187 #error "wrong value for __cpp_variadic_templates"
190 #if check(initializer_lists, 0, 200806, 200806, 200806)
191 #error "wrong value for __cpp_initializer_lists"
194 #if check(delegating_constructors, 0, 200604, 200604, 200604)
195 #error "wrong value for __cpp_delegating_constructors"
198 #if check(nsdmi, 0, 200809, 200809, 200809)
199 #error "wrong value for __cpp_nsdmi"
202 #if check(inheriting_constructors, 0, 201511, 201511, 201511)
203 #error "wrong value for __cpp_inheriting_constructors"
206 #if check(ref_qualifiers, 0, 200710, 200710, 200710)
207 #error "wrong value for __cpp_ref_qualifiers"
210 #if check(alias_templates, 0, 200704, 200704, 200704)
211 #error "wrong value for __cpp_alias_templates"
214 // --- C++98 features ---
216 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
217 #error "wrong value for __cpp_rtti"
220 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
221 #error "wrong value for __cpp_exceptions"
224 // --- TS features --
226 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
227 #error "wrong value for __cpp_experimental_concepts"
230 #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
231 #error "wrong value for __cpp_coroutines"