blob: f7a4ce12985cbf7931dac262069c310f46488dc4 [file] [log] [blame]
Richard Smithb02043c2016-09-28 19:44:50 +00001// 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 -DNO_EXCEPTIONS -DCOROUTINES -verify %s
Richard Smith91e474f2013-11-27 22:58:16 +00009
10// expected-no-diagnostics
11
Nico Weberb2348f42016-01-19 15:15:31 +000012// FIXME using `defined` in a macro has undefined behavior.
Richard Smith91e474f2013-11-27 22:58:16 +000013#if __cplusplus < 201103L
JF Bastiene3c13a82016-03-22 21:12:48 +000014#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 Smith91e474f2013-11-27 22:58:16 +000019#else
JF Bastiene3c13a82016-03-22 21:12:48 +000020#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
Richard Smith91e474f2013-11-27 22:58:16 +000021#endif
22
Richard Smithb02043c2016-09-28 19:44:50 +000023// --- C++17 features ---
24
Richard Smith38d91d42016-09-28 20:26:06 +000025#if check(hex_float, 0, 0, 0, 201603)
26#error "wrong value for __cpp_hex_float"
27#endif
28
Richard Smith6e4bedc2016-09-28 20:42:56 +000029#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, 0) // FIXME: provisional name
34// FIXME: value shuld be 201606 for cxx1z once implemented
35#error "wrong value for __cpp_aligned_new"
36#endif
37
Richard Smithb02043c2016-09-28 19:44:50 +000038#if check(noexcept_function_type, 0, 0, 0, 0)
Richard Smith38d91d42016-09-28 20:26:06 +000039// FIXME: value shuld be 201510 for cxx1z once implemented
Richard Smithb02043c2016-09-28 19:44:50 +000040#error "wrong value for __cpp_noexcept_function_type"
41#endif
42
Richard Smith38d91d42016-09-28 20:26:06 +000043#if check(fold_expressions, 0, 0, 0, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +000044#error "wrong value for __cpp_fold_expressions"
45#endif
46
Richard Smith38d91d42016-09-28 20:26:06 +000047#if check(capture_star_this, 0, 0, 0, 201603)
48#error "wrong value for __cpp_capture_star_this"
49#endif
50
51// FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support
52
Richard Smith6e4bedc2016-09-28 20:42:56 +000053#if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
54#error "wrong value for __cpp_if_constexpr"
55#endif
56
Richard Smith38d91d42016-09-28 20:26:06 +000057// range_based_for checked below
58
Richard Smithb02043c2016-09-28 19:44:50 +000059// static_assert checked below
60
Richard Smith6e4bedc2016-09-28 20:42:56 +000061#if check(template_auto, 0, 0, 0, 0) // FIXME: provisional name
62// FIXME: value shuld be 201606 for cxx1z once implemented
63#error "wrong value for __cpp_template_auto"
64#endif
65
Richard Smithb02043c2016-09-28 19:44:50 +000066#if check(namespace_attributes, 0, 0, 0, 201411)
67// FIXME: allowed without warning in C++14 and C++11
68#error "wrong value for __cpp_namespace_attributes"
69#endif
70
71#if check(enumerator_attributes, 0, 0, 0, 201411)
72// FIXME: allowed without warning in C++14 and C++11
73#error "wrong value for __cpp_enumerator_attributes"
74#endif
75
76#if check(nested_namespace_definitions, 0, 0, 0, 201411)
77#error "wrong value for __cpp_nested_namespace_definitions"
78#endif
79
Richard Smith38d91d42016-09-28 20:26:06 +000080#if check(aggregate_bases, 0, 0, 0, 201603)
81#error "wrong value for __cpp_aggregate_bases"
82#endif
83
Richard Smith6e4bedc2016-09-28 20:42:56 +000084// FIXME: structured_bindings / decomposition_decl name not yet settled, and
85// Clang implementation is incomplete.
86
Richard Smithb02043c2016-09-28 19:44:50 +000087#if check(nontype_template_args, 0, 0, 0, 201411)
88#error "wrong value for __cpp_nontype_template_args"
89#endif
90
91// --- C++14 features ---
92
JF Bastiene3c13a82016-03-22 21:12:48 +000093#if check(binary_literals, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +000094#error "wrong value for __cpp_binary_literals"
95#endif
96
Richard Smithb02043c2016-09-28 19:44:50 +000097// (Removed from SD-6.)
JF Bastiene3c13a82016-03-22 21:12:48 +000098#if check(digit_separators, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +000099#error "wrong value for __cpp_digit_separators"
100#endif
101
JF Bastiene3c13a82016-03-22 21:12:48 +0000102#if check(init_captures, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000103#error "wrong value for __cpp_init_captures"
104#endif
105
JF Bastiene3c13a82016-03-22 21:12:48 +0000106#if check(generic_lambdas, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000107#error "wrong value for __cpp_generic_lambdas"
108#endif
109
JF Bastiene3c13a82016-03-22 21:12:48 +0000110#if check(sized_deallocation, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000111#error "wrong value for __cpp_sized_deallocation"
112#endif
113
Richard Smithb02043c2016-09-28 19:44:50 +0000114// constexpr checked below
Richard Smith91e474f2013-11-27 22:58:16 +0000115
JF Bastiene3c13a82016-03-22 21:12:48 +0000116#if check(decltype_auto, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000117#error "wrong value for __cpp_decltype_auto"
118#endif
119
JF Bastiene3c13a82016-03-22 21:12:48 +0000120#if check(return_type_deduction, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000121#error "wrong value for __cpp_return_type_deduction"
122#endif
123
JF Bastiene3c13a82016-03-22 21:12:48 +0000124#if check(runtime_arrays, 0, 0, 0, 0)
Richard Smith91e474f2013-11-27 22:58:16 +0000125#error "wrong value for __cpp_runtime_arrays"
126#endif
127
JF Bastiene3c13a82016-03-22 21:12:48 +0000128#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000129#error "wrong value for __cpp_aggregate_nsdmi"
130#endif
131
JF Bastiene3c13a82016-03-22 21:12:48 +0000132#if check(variable_templates, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000133#error "wrong value for __cpp_variable_templates"
134#endif
135
Richard Smithb02043c2016-09-28 19:44:50 +0000136// --- C++11 features ---
137
JF Bastiene3c13a82016-03-22 21:12:48 +0000138#if check(unicode_characters, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000139#error "wrong value for __cpp_unicode_characters"
140#endif
141
JF Bastiene3c13a82016-03-22 21:12:48 +0000142#if check(raw_strings, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000143#error "wrong value for __cpp_raw_strings"
144#endif
145
JF Bastiene3c13a82016-03-22 21:12:48 +0000146#if check(unicode_literals, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000147#error "wrong value for __cpp_unicode_literals"
148#endif
149
JF Bastiene3c13a82016-03-22 21:12:48 +0000150#if check(user_defined_literals, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000151#error "wrong value for __cpp_user_defined_literals"
152#endif
153
JF Bastiene3c13a82016-03-22 21:12:48 +0000154#if check(lambdas, 0, 200907, 200907, 200907)
Richard Smith91e474f2013-11-27 22:58:16 +0000155#error "wrong value for __cpp_lambdas"
156#endif
157
Richard Smithb02043c2016-09-28 19:44:50 +0000158#if check(constexpr, 0, 200704, 201304, 201304)
159#error "wrong value for __cpp_constexpr"
160#endif
161
Richard Smith38d91d42016-09-28 20:26:06 +0000162#if check(range_based_for, 0, 200907, 200907, 201603)
Richard Smith38af8562014-11-12 21:16:38 +0000163#error "wrong value for __cpp_range_based_for"
164#endif
165
Richard Smithb02043c2016-09-28 19:44:50 +0000166#if check(static_assert, 0, 200410, 200410, 201411)
Richard Smith91e474f2013-11-27 22:58:16 +0000167#error "wrong value for __cpp_static_assert"
168#endif
169
JF Bastiene3c13a82016-03-22 21:12:48 +0000170#if check(decltype, 0, 200707, 200707, 200707)
Richard Smith91e474f2013-11-27 22:58:16 +0000171#error "wrong value for __cpp_decltype"
172#endif
173
JF Bastiene3c13a82016-03-22 21:12:48 +0000174#if check(attributes, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000175#error "wrong value for __cpp_attributes"
176#endif
177
JF Bastiene3c13a82016-03-22 21:12:48 +0000178#if check(rvalue_references, 0, 200610, 200610, 200610)
Richard Smith91e474f2013-11-27 22:58:16 +0000179#error "wrong value for __cpp_rvalue_references"
180#endif
181
JF Bastiene3c13a82016-03-22 21:12:48 +0000182#if check(variadic_templates, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000183#error "wrong value for __cpp_variadic_templates"
184#endif
Richard Smith38af8562014-11-12 21:16:38 +0000185
JF Bastiene3c13a82016-03-22 21:12:48 +0000186#if check(initializer_lists, 0, 200806, 200806, 200806)
Richard Smith38af8562014-11-12 21:16:38 +0000187#error "wrong value for __cpp_initializer_lists"
188#endif
189
JF Bastiene3c13a82016-03-22 21:12:48 +0000190#if check(delegating_constructors, 0, 200604, 200604, 200604)
Richard Smith38af8562014-11-12 21:16:38 +0000191#error "wrong value for __cpp_delegating_constructors"
192#endif
193
JF Bastiene3c13a82016-03-22 21:12:48 +0000194#if check(nsdmi, 0, 200809, 200809, 200809)
Richard Smith38af8562014-11-12 21:16:38 +0000195#error "wrong value for __cpp_nsdmi"
196#endif
197
Richard Smithb02043c2016-09-28 19:44:50 +0000198#if check(inheriting_constructors, 0, 201511, 201511, 201511)
Richard Smith38af8562014-11-12 21:16:38 +0000199#error "wrong value for __cpp_inheriting_constructors"
200#endif
201
JF Bastiene3c13a82016-03-22 21:12:48 +0000202#if check(ref_qualifiers, 0, 200710, 200710, 200710)
Richard Smith38af8562014-11-12 21:16:38 +0000203#error "wrong value for __cpp_ref_qualifiers"
204#endif
205
JF Bastiene3c13a82016-03-22 21:12:48 +0000206#if check(alias_templates, 0, 200704, 200704, 200704)
Richard Smith38af8562014-11-12 21:16:38 +0000207#error "wrong value for __cpp_alias_templates"
208#endif
Faisal Vali24d59d12015-05-22 01:11:10 +0000209
Richard Smithb02043c2016-09-28 19:44:50 +0000210// --- C++98 features ---
211
212#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
213#error "wrong value for __cpp_rtti"
214#endif
215
216#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
217#error "wrong value for __cpp_exceptions"
218#endif
219
220// --- TS features --
221
JF Bastiene3c13a82016-03-22 21:12:48 +0000222#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
Faisal Vali24d59d12015-05-22 01:11:10 +0000223#error "wrong value for __cpp_experimental_concepts"
224#endif
Richard Smith3fa73f32015-10-22 04:27:47 +0000225
226#if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
227#error "wrong value for __cpp_coroutines"
228#endif