Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 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 |
Gor Nishanov | 4ffb434 | 2016-10-02 03:31:58 +0000 | [diff] [blame] | 8 | // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 9 | |
| 10 | // expected-no-diagnostics |
| 11 | |
Nico Weber | b2348f4 | 2016-01-19 15:15:31 +0000 | [diff] [blame] | 12 | // FIXME using `defined` in a macro has undefined behavior. |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 13 | #if __cplusplus < 201103L |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 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 |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 19 | #else |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 20 | #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 21 | #endif |
| 22 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 23 | // --- C++17 features --- |
| 24 | |
Richard Smith | cb0ccb0 | 2016-12-19 04:16:03 +0000 | [diff] [blame] | 25 | #if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name |
| 26 | #error "wrong value for __cpp_variadic_using" |
| 27 | #endif |
| 28 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 29 | #if check(hex_float, 0, 0, 0, 201603) |
| 30 | #error "wrong value for __cpp_hex_float" |
| 31 | #endif |
| 32 | |
Richard Smith | 6e4bedc | 2016-09-28 20:42:56 +0000 | [diff] [blame] | 33 | #if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name |
| 34 | #error "wrong value for __cpp_inline_variables" |
| 35 | #endif |
| 36 | |
Richard Smith | f5d8a75 | 2016-10-10 06:55:42 +0000 | [diff] [blame] | 37 | #if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name |
Richard Smith | 6e4bedc | 2016-09-28 20:42:56 +0000 | [diff] [blame] | 38 | #error "wrong value for __cpp_aligned_new" |
| 39 | #endif |
| 40 | |
Richard Smith | 6cc02c2 | 2016-12-02 02:02:23 +0000 | [diff] [blame] | 41 | #if check(noexcept_function_type, 0, 0, 0, 201510) |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 42 | #error "wrong value for __cpp_noexcept_function_type" |
| 43 | #endif |
| 44 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 45 | #if check(fold_expressions, 0, 0, 0, 201603) |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 46 | #error "wrong value for __cpp_fold_expressions" |
| 47 | #endif |
| 48 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 49 | #if check(capture_star_this, 0, 0, 0, 201603) |
| 50 | #error "wrong value for __cpp_capture_star_this" |
| 51 | #endif |
| 52 | |
| 53 | // FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support |
| 54 | |
Richard Smith | 6e4bedc | 2016-09-28 20:42:56 +0000 | [diff] [blame] | 55 | #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name |
| 56 | #error "wrong value for __cpp_if_constexpr" |
| 57 | #endif |
| 58 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 59 | // range_based_for checked below |
| 60 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 61 | // static_assert checked below |
| 62 | |
Richard Smith | 27143d8 | 2016-09-29 00:08:05 +0000 | [diff] [blame] | 63 | #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name |
Richard Smith | 6e4bedc | 2016-09-28 20:42:56 +0000 | [diff] [blame] | 64 | #error "wrong value for __cpp_template_auto" |
| 65 | #endif |
| 66 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 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" |
| 70 | #endif |
| 71 | |
| 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" |
| 75 | #endif |
| 76 | |
| 77 | #if check(nested_namespace_definitions, 0, 0, 0, 201411) |
| 78 | #error "wrong value for __cpp_nested_namespace_definitions" |
| 79 | #endif |
| 80 | |
Richard Smith | dbe74e0 | 2016-12-19 04:21:36 +0000 | [diff] [blame] | 81 | // inheriting_constructors checked below |
| 82 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 83 | #if check(aggregate_bases, 0, 0, 0, 201603) |
| 84 | #error "wrong value for __cpp_aggregate_bases" |
| 85 | #endif |
| 86 | |
Richard Smith | dbe74e0 | 2016-12-19 04:21:36 +0000 | [diff] [blame] | 87 | #if check(structured_bindings, 0, 0, 0, 201606) |
| 88 | #error "wrong value for __cpp_structured_bindings" |
| 89 | #endif |
Richard Smith | 6e4bedc | 2016-09-28 20:42:56 +0000 | [diff] [blame] | 90 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 91 | #if check(nontype_template_args, 0, 0, 0, 201411) |
| 92 | #error "wrong value for __cpp_nontype_template_args" |
| 93 | #endif |
| 94 | |
Richard Smith | cbe0793 | 2017-02-14 00:55:25 +0000 | [diff] [blame^] | 95 | #if check(template_template_args, 0, 0, 0, 0) // FIXME: should be 201611 when feature is enabled |
| 96 | #error "wrong value for __cpp_template_template_args" |
| 97 | #endif |
| 98 | |
| 99 | #if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name |
| 100 | #error "wrong value for __cpp_deduction_guides" |
| 101 | #endif |
| 102 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 103 | // --- C++14 features --- |
| 104 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 105 | #if check(binary_literals, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 106 | #error "wrong value for __cpp_binary_literals" |
| 107 | #endif |
| 108 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 109 | // (Removed from SD-6.) |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 110 | #if check(digit_separators, 0, 0, 201309, 201309) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 111 | #error "wrong value for __cpp_digit_separators" |
| 112 | #endif |
| 113 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 114 | #if check(init_captures, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 115 | #error "wrong value for __cpp_init_captures" |
| 116 | #endif |
| 117 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 118 | #if check(generic_lambdas, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 119 | #error "wrong value for __cpp_generic_lambdas" |
| 120 | #endif |
| 121 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 122 | #if check(sized_deallocation, 0, 0, 201309, 201309) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 123 | #error "wrong value for __cpp_sized_deallocation" |
| 124 | #endif |
| 125 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 126 | // constexpr checked below |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 127 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 128 | #if check(decltype_auto, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 129 | #error "wrong value for __cpp_decltype_auto" |
| 130 | #endif |
| 131 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 132 | #if check(return_type_deduction, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 133 | #error "wrong value for __cpp_return_type_deduction" |
| 134 | #endif |
| 135 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 136 | #if check(runtime_arrays, 0, 0, 0, 0) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 137 | #error "wrong value for __cpp_runtime_arrays" |
| 138 | #endif |
| 139 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 140 | #if check(aggregate_nsdmi, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 141 | #error "wrong value for __cpp_aggregate_nsdmi" |
| 142 | #endif |
| 143 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 144 | #if check(variable_templates, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 145 | #error "wrong value for __cpp_variable_templates" |
| 146 | #endif |
| 147 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 148 | // --- C++11 features --- |
| 149 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 150 | #if check(unicode_characters, 0, 200704, 200704, 200704) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 151 | #error "wrong value for __cpp_unicode_characters" |
| 152 | #endif |
| 153 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 154 | #if check(raw_strings, 0, 200710, 200710, 200710) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 155 | #error "wrong value for __cpp_raw_strings" |
| 156 | #endif |
| 157 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 158 | #if check(unicode_literals, 0, 200710, 200710, 200710) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 159 | #error "wrong value for __cpp_unicode_literals" |
| 160 | #endif |
| 161 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 162 | #if check(user_defined_literals, 0, 200809, 200809, 200809) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 163 | #error "wrong value for __cpp_user_defined_literals" |
| 164 | #endif |
| 165 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 166 | #if check(lambdas, 0, 200907, 200907, 200907) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 167 | #error "wrong value for __cpp_lambdas" |
| 168 | #endif |
| 169 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 170 | #if check(constexpr, 0, 200704, 201304, 201304) |
| 171 | #error "wrong value for __cpp_constexpr" |
| 172 | #endif |
| 173 | |
Richard Smith | 38d91d4 | 2016-09-28 20:26:06 +0000 | [diff] [blame] | 174 | #if check(range_based_for, 0, 200907, 200907, 201603) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 175 | #error "wrong value for __cpp_range_based_for" |
| 176 | #endif |
| 177 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 178 | #if check(static_assert, 0, 200410, 200410, 201411) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 179 | #error "wrong value for __cpp_static_assert" |
| 180 | #endif |
| 181 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 182 | #if check(decltype, 0, 200707, 200707, 200707) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 183 | #error "wrong value for __cpp_decltype" |
| 184 | #endif |
| 185 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 186 | #if check(attributes, 0, 200809, 200809, 200809) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 187 | #error "wrong value for __cpp_attributes" |
| 188 | #endif |
| 189 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 190 | #if check(rvalue_references, 0, 200610, 200610, 200610) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 191 | #error "wrong value for __cpp_rvalue_references" |
| 192 | #endif |
| 193 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 194 | #if check(variadic_templates, 0, 200704, 200704, 200704) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 195 | #error "wrong value for __cpp_variadic_templates" |
| 196 | #endif |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 197 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 198 | #if check(initializer_lists, 0, 200806, 200806, 200806) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 199 | #error "wrong value for __cpp_initializer_lists" |
| 200 | #endif |
| 201 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 202 | #if check(delegating_constructors, 0, 200604, 200604, 200604) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 203 | #error "wrong value for __cpp_delegating_constructors" |
| 204 | #endif |
| 205 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 206 | #if check(nsdmi, 0, 200809, 200809, 200809) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 207 | #error "wrong value for __cpp_nsdmi" |
| 208 | #endif |
| 209 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 210 | #if check(inheriting_constructors, 0, 201511, 201511, 201511) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 211 | #error "wrong value for __cpp_inheriting_constructors" |
| 212 | #endif |
| 213 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 214 | #if check(ref_qualifiers, 0, 200710, 200710, 200710) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 215 | #error "wrong value for __cpp_ref_qualifiers" |
| 216 | #endif |
| 217 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 218 | #if check(alias_templates, 0, 200704, 200704, 200704) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 219 | #error "wrong value for __cpp_alias_templates" |
| 220 | #endif |
Faisal Vali | 24d59d1 | 2015-05-22 01:11:10 +0000 | [diff] [blame] | 221 | |
Richard Smith | b02043c | 2016-09-28 19:44:50 +0000 | [diff] [blame] | 222 | // --- C++98 features --- |
| 223 | |
| 224 | #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711) |
| 225 | #error "wrong value for __cpp_rtti" |
| 226 | #endif |
| 227 | |
| 228 | #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711) |
| 229 | #error "wrong value for __cpp_exceptions" |
| 230 | #endif |
| 231 | |
| 232 | // --- TS features -- |
| 233 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 234 | #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS) |
Faisal Vali | 24d59d1 | 2015-05-22 01:11:10 +0000 | [diff] [blame] | 235 | #error "wrong value for __cpp_experimental_concepts" |
| 236 | #endif |
Richard Smith | 3fa73f3 | 2015-10-22 04:27:47 +0000 | [diff] [blame] | 237 | |
| 238 | #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines) |
| 239 | #error "wrong value for __cpp_coroutines" |
| 240 | #endif |