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 9 10 // expected-no-diagnostics 11 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 19 #else 20 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z 21 #endif 22 23 // --- C++17 features --- 24 25 #if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name 26 #error "wrong value for __cpp_variadic_using" 27 #endif 28 29 #if check(hex_float, 0, 0, 0, 201603) 30 #error "wrong value for __cpp_hex_float" 31 #endif 32 33 #if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name 34 #error "wrong value for __cpp_inline_variables" 35 #endif 36 37 #if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name 38 #error "wrong value for __cpp_aligned_new" 39 #endif 40 41 #if check(noexcept_function_type, 0, 0, 0, 201510) 42 #error "wrong value for __cpp_noexcept_function_type" 43 #endif 44 45 #if check(fold_expressions, 0, 0, 0, 201603) 46 #error "wrong value for __cpp_fold_expressions" 47 #endif 48 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 55 #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name 56 #error "wrong value for __cpp_if_constexpr" 57 #endif 58 59 // range_based_for checked below 60 61 // static_assert checked below 62 63 #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name 64 #error "wrong value for __cpp_template_auto" 65 #endif 66 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 81 // inheriting_constructors checked below 82 83 #if check(aggregate_bases, 0, 0, 0, 201603) 84 #error "wrong value for __cpp_aggregate_bases" 85 #endif 86 87 #if check(structured_bindings, 0, 0, 0, 201606) 88 #error "wrong value for __cpp_structured_bindings" 89 #endif 90 91 #if check(nontype_template_args, 0, 0, 0, 201411) 92 #error "wrong value for __cpp_nontype_template_args" 93 #endif 94 95 // --- C++14 features --- 96 97 #if check(binary_literals, 0, 0, 201304, 201304) 98 #error "wrong value for __cpp_binary_literals" 99 #endif 100 101 // (Removed from SD-6.) 102 #if check(digit_separators, 0, 0, 201309, 201309) 103 #error "wrong value for __cpp_digit_separators" 104 #endif 105 106 #if check(init_captures, 0, 0, 201304, 201304) 107 #error "wrong value for __cpp_init_captures" 108 #endif 109 110 #if check(generic_lambdas, 0, 0, 201304, 201304) 111 #error "wrong value for __cpp_generic_lambdas" 112 #endif 113 114 #if check(sized_deallocation, 0, 0, 201309, 201309) 115 #error "wrong value for __cpp_sized_deallocation" 116 #endif 117 118 // constexpr checked below 119 120 #if check(decltype_auto, 0, 0, 201304, 201304) 121 #error "wrong value for __cpp_decltype_auto" 122 #endif 123 124 #if check(return_type_deduction, 0, 0, 201304, 201304) 125 #error "wrong value for __cpp_return_type_deduction" 126 #endif 127 128 #if check(runtime_arrays, 0, 0, 0, 0) 129 #error "wrong value for __cpp_runtime_arrays" 130 #endif 131 132 #if check(aggregate_nsdmi, 0, 0, 201304, 201304) 133 #error "wrong value for __cpp_aggregate_nsdmi" 134 #endif 135 136 #if check(variable_templates, 0, 0, 201304, 201304) 137 #error "wrong value for __cpp_variable_templates" 138 #endif 139 140 // --- C++11 features --- 141 142 #if check(unicode_characters, 0, 200704, 200704, 200704) 143 #error "wrong value for __cpp_unicode_characters" 144 #endif 145 146 #if check(raw_strings, 0, 200710, 200710, 200710) 147 #error "wrong value for __cpp_raw_strings" 148 #endif 149 150 #if check(unicode_literals, 0, 200710, 200710, 200710) 151 #error "wrong value for __cpp_unicode_literals" 152 #endif 153 154 #if check(user_defined_literals, 0, 200809, 200809, 200809) 155 #error "wrong value for __cpp_user_defined_literals" 156 #endif 157 158 #if check(lambdas, 0, 200907, 200907, 200907) 159 #error "wrong value for __cpp_lambdas" 160 #endif 161 162 #if check(constexpr, 0, 200704, 201304, 201304) 163 #error "wrong value for __cpp_constexpr" 164 #endif 165 166 #if check(range_based_for, 0, 200907, 200907, 201603) 167 #error "wrong value for __cpp_range_based_for" 168 #endif 169 170 #if check(static_assert, 0, 200410, 200410, 201411) 171 #error "wrong value for __cpp_static_assert" 172 #endif 173 174 #if check(decltype, 0, 200707, 200707, 200707) 175 #error "wrong value for __cpp_decltype" 176 #endif 177 178 #if check(attributes, 0, 200809, 200809, 200809) 179 #error "wrong value for __cpp_attributes" 180 #endif 181 182 #if check(rvalue_references, 0, 200610, 200610, 200610) 183 #error "wrong value for __cpp_rvalue_references" 184 #endif 185 186 #if check(variadic_templates, 0, 200704, 200704, 200704) 187 #error "wrong value for __cpp_variadic_templates" 188 #endif 189 190 #if check(initializer_lists, 0, 200806, 200806, 200806) 191 #error "wrong value for __cpp_initializer_lists" 192 #endif 193 194 #if check(delegating_constructors, 0, 200604, 200604, 200604) 195 #error "wrong value for __cpp_delegating_constructors" 196 #endif 197 198 #if check(nsdmi, 0, 200809, 200809, 200809) 199 #error "wrong value for __cpp_nsdmi" 200 #endif 201 202 #if check(inheriting_constructors, 0, 201511, 201511, 201511) 203 #error "wrong value for __cpp_inheriting_constructors" 204 #endif 205 206 #if check(ref_qualifiers, 0, 200710, 200710, 200710) 207 #error "wrong value for __cpp_ref_qualifiers" 208 #endif 209 210 #if check(alias_templates, 0, 200704, 200704, 200704) 211 #error "wrong value for __cpp_alias_templates" 212 #endif 213 214 // --- C++98 features --- 215 216 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711) 217 #error "wrong value for __cpp_rtti" 218 #endif 219 220 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711) 221 #error "wrong value for __cpp_exceptions" 222 #endif 223 224 // --- TS features -- 225 226 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS) 227 #error "wrong value for __cpp_experimental_concepts" 228 #endif 229 230 #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines) 231 #error "wrong value for __cpp_coroutines" 232 #endif 233