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