Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++98 -verify %s |
| 2 | // RUN: %clang_cc1 -std=c++11 -verify %s |
Reid Kleckner | 7ffc3fb | 2015-03-20 00:31:07 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s |
| 5 | // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s |
| 6 | // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s |
Richard Smith | 3fa73f3 | 2015-10-22 04:27:47 +0000 | [diff] [blame] | 7 | // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 8 | |
| 9 | // expected-no-diagnostics |
| 10 | |
Nico Weber | b2348f4 | 2016-01-19 15:15:31 +0000 | [diff] [blame] | 11 | // FIXME using `defined` in a macro has undefined behavior. |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 12 | #if __cplusplus < 201103L |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 13 | #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98 |
| 14 | #elif __cplusplus < 201402L |
| 15 | #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11 |
| 16 | #elif __cplusplus < 201406L |
| 17 | #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] | 18 | #else |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 19 | #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] | 20 | #endif |
| 21 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 22 | #if check(binary_literals, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 23 | #error "wrong value for __cpp_binary_literals" |
| 24 | #endif |
| 25 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 26 | #if check(digit_separators, 0, 0, 201309, 201309) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 27 | #error "wrong value for __cpp_digit_separators" |
| 28 | #endif |
| 29 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 30 | #if check(init_captures, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 31 | #error "wrong value for __cpp_init_captures" |
| 32 | #endif |
| 33 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 34 | #if check(generic_lambdas, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 35 | #error "wrong value for __cpp_generic_lambdas" |
| 36 | #endif |
| 37 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 38 | #if check(sized_deallocation, 0, 0, 201309, 201309) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 39 | #error "wrong value for __cpp_sized_deallocation" |
| 40 | #endif |
| 41 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 42 | #if check(constexpr, 0, 200704, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 43 | #error "wrong value for __cpp_constexpr" |
| 44 | #endif |
| 45 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 46 | #if check(decltype_auto, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 47 | #error "wrong value for __cpp_decltype_auto" |
| 48 | #endif |
| 49 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 50 | #if check(return_type_deduction, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 51 | #error "wrong value for __cpp_return_type_deduction" |
| 52 | #endif |
| 53 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 54 | #if check(runtime_arrays, 0, 0, 0, 0) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 55 | #error "wrong value for __cpp_runtime_arrays" |
| 56 | #endif |
| 57 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 58 | #if check(aggregate_nsdmi, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 59 | #error "wrong value for __cpp_aggregate_nsdmi" |
| 60 | #endif |
| 61 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 62 | #if check(variable_templates, 0, 0, 201304, 201304) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 63 | #error "wrong value for __cpp_variable_templates" |
| 64 | #endif |
| 65 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 66 | #if check(unicode_characters, 0, 200704, 200704, 200704) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 67 | #error "wrong value for __cpp_unicode_characters" |
| 68 | #endif |
| 69 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 70 | #if check(raw_strings, 0, 200710, 200710, 200710) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 71 | #error "wrong value for __cpp_raw_strings" |
| 72 | #endif |
| 73 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 74 | #if check(unicode_literals, 0, 200710, 200710, 200710) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 75 | #error "wrong value for __cpp_unicode_literals" |
| 76 | #endif |
| 77 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 78 | #if check(user_defined_literals, 0, 200809, 200809, 200809) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 79 | #error "wrong value for __cpp_user_defined_literals" |
| 80 | #endif |
| 81 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 82 | #if check(lambdas, 0, 200907, 200907, 200907) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 83 | #error "wrong value for __cpp_lambdas" |
| 84 | #endif |
| 85 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 86 | #if check(range_based_for, 0, 200907, 200907, 200907) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 87 | #error "wrong value for __cpp_range_based_for" |
| 88 | #endif |
| 89 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 90 | #if check(static_assert, 0, 200410, 200410, 200410) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 91 | #error "wrong value for __cpp_static_assert" |
| 92 | #endif |
| 93 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 94 | #if check(decltype, 0, 200707, 200707, 200707) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 95 | #error "wrong value for __cpp_decltype" |
| 96 | #endif |
| 97 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 98 | #if check(attributes, 0, 200809, 200809, 200809) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 99 | #error "wrong value for __cpp_attributes" |
| 100 | #endif |
| 101 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 102 | #if check(rvalue_references, 0, 200610, 200610, 200610) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 103 | #error "wrong value for __cpp_rvalue_references" |
| 104 | #endif |
| 105 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 106 | #if check(variadic_templates, 0, 200704, 200704, 200704) |
Richard Smith | 91e474f | 2013-11-27 22:58:16 +0000 | [diff] [blame] | 107 | #error "wrong value for __cpp_variadic_templates" |
| 108 | #endif |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 109 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 110 | #if check(initializer_lists, 0, 200806, 200806, 200806) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 111 | #error "wrong value for __cpp_initializer_lists" |
| 112 | #endif |
| 113 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 114 | #if check(delegating_constructors, 0, 200604, 200604, 200604) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 115 | #error "wrong value for __cpp_delegating_constructors" |
| 116 | #endif |
| 117 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 118 | #if check(nsdmi, 0, 200809, 200809, 200809) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 119 | #error "wrong value for __cpp_nsdmi" |
| 120 | #endif |
| 121 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 122 | #if check(inheriting_constructors, 0, 200802, 200802, 200802) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 123 | #error "wrong value for __cpp_inheriting_constructors" |
| 124 | #endif |
| 125 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 126 | #if check(ref_qualifiers, 0, 200710, 200710, 200710) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 127 | #error "wrong value for __cpp_ref_qualifiers" |
| 128 | #endif |
| 129 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 130 | #if check(alias_templates, 0, 200704, 200704, 200704) |
Richard Smith | 38af856 | 2014-11-12 21:16:38 +0000 | [diff] [blame] | 131 | #error "wrong value for __cpp_alias_templates" |
| 132 | #endif |
Faisal Vali | 24d59d1 | 2015-05-22 01:11:10 +0000 | [diff] [blame] | 133 | |
JF Bastien | e3c13a8 | 2016-03-22 21:12:48 +0000 | [diff] [blame] | 134 | #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS) |
Faisal Vali | 24d59d1 | 2015-05-22 01:11:10 +0000 | [diff] [blame] | 135 | #error "wrong value for __cpp_experimental_concepts" |
| 136 | #endif |
Richard Smith | 3fa73f3 | 2015-10-22 04:27:47 +0000 | [diff] [blame] | 137 | |
| 138 | #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines) |
| 139 | #error "wrong value for __cpp_coroutines" |
| 140 | #endif |