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 7 // 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 14 15 // expected-no-diagnostics 16 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) 28 #else 29 #define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx23 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx23) 30 #endif 31 32 // --- C++20 features --- 33 34 #if check(aggregate_paren_init, 0, 0, 0, 0, 0, 0) 35 // FIXME: 201902 in C++20 36 #error "wrong value for __cpp_aggregate_paren_init" 37 #endif 38 39 #if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811, 201811) : \ 40 defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0, 0) : \ 41 check(char8_t, 0, 0, 0, 0, 201811, 201811) 42 #error "wrong value for __cpp_char8_t" 43 #endif 44 45 #if check(concepts, 0, 0, 0, 0, 201907, 201907) 46 #error "wrong value for __cpp_concepts" 47 #endif 48 49 #if check(conditional_explicit, 0, 0, 0, 0, 201806, 201806) 50 #error "wrong value for __cpp_conditional_explicit" 51 #endif 52 53 #if check(consteval, 0, 0, 0, 0, 0, 0) 54 // FIXME: 201811 in C++20 55 #error "wrong value for __cpp_consteval" 56 #endif 57 58 // constexpr checked below 59 60 #if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907, 201907) 61 #error "wrong value for __cpp_constexpr_dynamic_alloc" 62 #endif 63 64 #if check(constexpr_in_decltype, 0, 201711, 201711, 201711, 201711, 201711) 65 #error "wrong value for __cpp_constexpr_in_decltype" 66 #endif 67 68 #if check(constinit, 0, 0, 0, 0, 201907, 201907) 69 #error "wrong value for __cpp_constinit" 70 #endif 71 72 // deduction_guides checked below 73 74 #if check(designated_initializers, 0, 0, 0, 0, 201707, 201707) 75 #error "wrong value for __cpp_designated_initializers" 76 #endif 77 78 // generic_lambdas checked below 79 80 #if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806, 201806) 81 #error "wrong value for __cpp_impl_destroying_delete" 82 #endif 83 84 #if check(impl_three_way_comparison, 0, 0, 0, 0, 201907, 201907) 85 #error "wrong value for __cpp_impl_three_way_comparison" 86 #endif 87 88 // init_captures checked below 89 90 #if check(modules, 0, 0, 0, 0, 0, 0) 91 // FIXME: 201907 in C++20 92 #error "wrong value for __cpp_modules" 93 #endif 94 95 #if check(using_enum, 0, 0, 0, 0, 0, 0) 96 // FIXME: 201907 in C++20 97 #error "wrong value for __cpp_using_enum" 98 #endif 99 100 // --- C++17 features --- 101 102 #if check(hex_float, 0, 0, 0, 201603, 201603, 201603) 103 #error "wrong value for __cpp_hex_float" 104 #endif 105 106 #if check(inline_variables, 0, 0, 0, 201606, 201606, 201606) 107 #error "wrong value for __cpp_inline_variables" 108 #endif 109 110 #if check(aligned_new, 0, 0, 0, 201606, 201606, 201606) 111 #error "wrong value for __cpp_aligned_new" 112 #endif 113 114 #if check(guaranteed_copy_elision, 0, 0, 0, 201606, 201606, 201606) 115 #error "wrong value for __cpp_guaranteed_copy_elision" 116 #endif 117 118 #if check(noexcept_function_type, 0, 0, 0, 201510, 201510, 201510) 119 #error "wrong value for __cpp_noexcept_function_type" 120 #endif 121 122 #if check(fold_expressions, 0, 0, 0, 201603, 201603, 201603) 123 #error "wrong value for __cpp_fold_expressions" 124 #endif 125 126 #if check(capture_star_this, 0, 0, 0, 201603, 201603, 201603) 127 #error "wrong value for __cpp_capture_star_this" 128 #endif 129 130 // constexpr checked below 131 132 #if check(if_constexpr, 0, 0, 0, 201606, 201606, 201606) 133 #error "wrong value for __cpp_if_constexpr" 134 #endif 135 136 // range_based_for checked below 137 138 // static_assert checked below 139 140 #if check(deduction_guides, 0, 0, 0, 201703, 201703, 201703) 141 // FIXME: 201907 in C++20 142 #error "wrong value for __cpp_deduction_guides" 143 #endif 144 145 #if check(nontype_template_parameter_auto, 0, 0, 0, 201606, 201606, 201606) 146 #error "wrong value for __cpp_nontype_template_parameter_auto" 147 #endif 148 149 // This is the old name (from P0096R4) for 150 // __cpp_nontype_template_parameter_auto 151 #if check(template_auto, 0, 0, 0, 201606, 201606, 201606) 152 #error "wrong value for __cpp_template_auto" 153 #endif 154 155 #if check(namespace_attributes, 0, 0, 0, 201411, 201411, 201411) 156 // FIXME: allowed without warning in C++14 and C++11 157 #error "wrong value for __cpp_namespace_attributes" 158 #endif 159 160 #if check(enumerator_attributes, 0, 0, 0, 201411, 201411, 201411) 161 // FIXME: allowed without warning in C++14 and C++11 162 #error "wrong value for __cpp_enumerator_attributes" 163 #endif 164 165 // This is an old name (from P0096R4), now removed from SD-6. 166 #if check(nested_namespace_definitions, 0, 0, 0, 201411, 201411, 201411) 167 #error "wrong value for __cpp_nested_namespace_definitions" 168 #endif 169 170 // inheriting_constructors checked below 171 172 #if check(variadic_using, 0, 0, 0, 201611, 201611, 201611) 173 #error "wrong value for __cpp_variadic_using" 174 #endif 175 176 #if check(aggregate_bases, 0, 0, 0, 201603, 201603, 201603) 177 #error "wrong value for __cpp_aggregate_bases" 178 #endif 179 180 #if check(structured_bindings, 0, 0, 0, 201606, 201606, 201606) 181 #error "wrong value for __cpp_structured_bindings" 182 #endif 183 184 #if check(nontype_template_args, 0, 0, 0, 201411, 201411, 201411) 185 // FIXME: 201911 in C++20 186 #error "wrong value for __cpp_nontype_template_args" 187 #endif 188 189 #if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \ 190 ? check(template_template_args, 0, 0, 0, 201611, 201611, 201611) \ 191 : check(template_template_args, 0, 0, 0, 0, 0, 0) 192 #error "wrong value for __cpp_template_template_args" 193 #endif 194 195 // --- C++14 features --- 196 197 #if check(binary_literals, 0, 0, 201304, 201304, 201304, 201304) 198 #error "wrong value for __cpp_binary_literals" 199 #endif 200 201 // (Removed from SD-6.) 202 #if check(digit_separators, 0, 0, 201309, 201309, 201309, 201309) 203 #error "wrong value for __cpp_digit_separators" 204 #endif 205 206 #if check(init_captures, 0, 0, 201304, 201304, 201803, 201803) 207 #error "wrong value for __cpp_init_captures" 208 #endif 209 210 #if check(generic_lambdas, 0, 0, 201304, 201304, 201707, 201707) 211 #error "wrong value for __cpp_generic_lambdas" 212 #endif 213 214 #if check(sized_deallocation, 0, 0, 201309, 201309, 201309, 201309) 215 #error "wrong value for __cpp_sized_deallocation" 216 #endif 217 218 // constexpr checked below 219 220 #if check(decltype_auto, 0, 0, 201304, 201304, 201304, 201304) 221 #error "wrong value for __cpp_decltype_auto" 222 #endif 223 224 #if check(return_type_deduction, 0, 0, 201304, 201304, 201304, 201304) 225 #error "wrong value for __cpp_return_type_deduction" 226 #endif 227 228 #if check(runtime_arrays, 0, 0, 0, 0, 0, 0) 229 #error "wrong value for __cpp_runtime_arrays" 230 #endif 231 232 #if check(aggregate_nsdmi, 0, 0, 201304, 201304, 201304, 201304) 233 #error "wrong value for __cpp_aggregate_nsdmi" 234 #endif 235 236 #if check(variable_templates, 0, 0, 201304, 201304, 201304, 201304) 237 #error "wrong value for __cpp_variable_templates" 238 #endif 239 240 // --- C++11 features --- 241 242 #if check(unicode_characters, 0, 200704, 200704, 200704, 200704, 200704) 243 #error "wrong value for __cpp_unicode_characters" 244 #endif 245 246 #if check(raw_strings, 0, 200710, 200710, 200710, 200710, 200710) 247 #error "wrong value for __cpp_raw_strings" 248 #endif 249 250 #if check(unicode_literals, 0, 200710, 200710, 200710, 200710, 200710) 251 #error "wrong value for __cpp_unicode_literals" 252 #endif 253 254 #if check(user_defined_literals, 0, 200809, 200809, 200809, 200809, 200809) 255 #error "wrong value for __cpp_user_defined_literals" 256 #endif 257 258 #if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0, 0, 0) : \ 259 check(threadsafe_static_init, 200806, 200806, 200806, 200806, 200806, 200806) 260 #error "wrong value for __cpp_threadsafe_static_init" 261 #endif 262 263 #if check(lambdas, 0, 200907, 200907, 200907, 200907, 200907) 264 #error "wrong value for __cpp_lambdas" 265 #endif 266 267 #if check(constexpr, 0, 200704, 201304, 201603, 201907, 201907) 268 #error "wrong value for __cpp_constexpr" 269 #endif 270 271 #if check(range_based_for, 0, 200907, 200907, 201603, 201603, 201603) 272 #error "wrong value for __cpp_range_based_for" 273 #endif 274 275 #if check(static_assert, 0, 200410, 200410, 201411, 201411, 201411) 276 #error "wrong value for __cpp_static_assert" 277 #endif 278 279 #if check(decltype, 0, 200707, 200707, 200707, 200707, 200707) 280 #error "wrong value for __cpp_decltype" 281 #endif 282 283 #if check(attributes, 0, 200809, 200809, 200809, 200809, 200809) 284 #error "wrong value for __cpp_attributes" 285 #endif 286 287 #if check(rvalue_references, 0, 200610, 200610, 200610, 200610, 200610) 288 #error "wrong value for __cpp_rvalue_references" 289 #endif 290 291 #if check(variadic_templates, 0, 200704, 200704, 200704, 200704, 200704) 292 #error "wrong value for __cpp_variadic_templates" 293 #endif 294 295 #if check(initializer_lists, 0, 200806, 200806, 200806, 200806, 200806) 296 #error "wrong value for __cpp_initializer_lists" 297 #endif 298 299 #if check(delegating_constructors, 0, 200604, 200604, 200604, 200604, 200604) 300 #error "wrong value for __cpp_delegating_constructors" 301 #endif 302 303 #if check(nsdmi, 0, 200809, 200809, 200809, 200809, 200809) 304 #error "wrong value for __cpp_nsdmi" 305 #endif 306 307 #if check(inheriting_constructors, 0, 201511, 201511, 201511, 201511, 201511) 308 #error "wrong value for __cpp_inheriting_constructors" 309 #endif 310 311 #if check(ref_qualifiers, 0, 200710, 200710, 200710, 200710, 200710) 312 #error "wrong value for __cpp_ref_qualifiers" 313 #endif 314 315 #if check(alias_templates, 0, 200704, 200704, 200704, 200704, 200704) 316 #error "wrong value for __cpp_alias_templates" 317 #endif 318 319 // --- C++98 features --- 320 321 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711, 199711, 199711) 322 #error "wrong value for __cpp_rtti" 323 #endif 324 325 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711, 199711, 199711) 326 #error "wrong value for __cpp_exceptions" 327 #endif 328 329 // --- TS features -- 330 331 #if defined(COROUTINES) ? check(coroutines, 201703, 201703, 201703, 201703, 201703, 201703) : check(coroutines, 0, 0, 0, 0, 201703, 201703) 332 #error "wrong value for __cpp_coroutines" 333 #endif 334