blob: e4fea0b5bb2a5d656220ca91c441cd51a7ce5747 [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
Richard Smithb02043c2016-09-28 19:44:50 +00003// RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
Richard Smith20eb9ba2018-06-14 00:40:20 +00004// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s
5// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fsized-deallocation -verify %s
6//
7// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
8// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
Tim Northover36bb6d52017-12-09 12:09:54 +00009// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
10// RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
Richard Smith3a8244d2018-05-01 05:02:45 +000011// RUN: %clang_cc1 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
Richard Smith28ddb912018-11-14 21:04:34 +000012// RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify -fsized-deallocation %s
Richard Smith91e474f2013-11-27 22:58:16 +000013
14// expected-no-diagnostics
15
Nico Weberb2348f42016-01-19 15:15:31 +000016// FIXME using `defined` in a macro has undefined behavior.
Richard Smith91e474f2013-11-27 22:58:16 +000017#if __cplusplus < 201103L
Richard Smith28ddb912018-11-14 21:04:34 +000018#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98)
JF Bastiene3c13a82016-03-22 21:12:48 +000019#elif __cplusplus < 201402L
Richard Smith28ddb912018-11-14 21:04:34 +000020#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11)
21#elif __cplusplus < 201703L
22#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14)
23#elif __cplusplus <= 201703L
24#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17)
Richard Smith91e474f2013-11-27 22:58:16 +000025#else
Richard Smith28ddb912018-11-14 21:04:34 +000026#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx20 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx20)
27#endif
28
29// --- C++20 features ---
30
31#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811) : \
32 defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0) : \
33 check(char8_t, 0, 0, 0, 0, 201811)
34#error "wrong value for __cpp_char8_t"
Richard Smith91e474f2013-11-27 22:58:16 +000035#endif
36
Richard Smithb02043c2016-09-28 19:44:50 +000037// --- C++17 features ---
38
Richard Smith28ddb912018-11-14 21:04:34 +000039#if check(hex_float, 0, 0, 0, 201603, 201603)
Richard Smith38d91d42016-09-28 20:26:06 +000040#error "wrong value for __cpp_hex_float"
41#endif
42
Richard Smith28ddb912018-11-14 21:04:34 +000043#if check(inline_variables, 0, 0, 0, 201606, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000044#error "wrong value for __cpp_inline_variables"
45#endif
46
Richard Smith28ddb912018-11-14 21:04:34 +000047#if check(aligned_new, 0, 0, 0, 201606, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000048#error "wrong value for __cpp_aligned_new"
49#endif
50
Richard Smith28ddb912018-11-14 21:04:34 +000051#if check(guaranteed_copy_elision, 0, 0, 0, 201606, 201606)
Richard Smith20eb9ba2018-06-14 00:40:20 +000052#error "wrong value for __cpp_guaranteed_copy_elision"
53#endif
54
Richard Smith28ddb912018-11-14 21:04:34 +000055#if check(noexcept_function_type, 0, 0, 0, 201510, 201510)
Richard Smithb02043c2016-09-28 19:44:50 +000056#error "wrong value for __cpp_noexcept_function_type"
57#endif
58
Richard Smith28ddb912018-11-14 21:04:34 +000059#if check(fold_expressions, 0, 0, 0, 201603, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +000060#error "wrong value for __cpp_fold_expressions"
61#endif
62
Richard Smith28ddb912018-11-14 21:04:34 +000063#if check(capture_star_this, 0, 0, 0, 201603, 201603)
Richard Smith38d91d42016-09-28 20:26:06 +000064#error "wrong value for __cpp_capture_star_this"
65#endif
66
Richard Smithb80bbca2017-02-21 23:58:29 +000067// constexpr checked below
Richard Smith38d91d42016-09-28 20:26:06 +000068
Richard Smith28ddb912018-11-14 21:04:34 +000069#if check(if_constexpr, 0, 0, 0, 201606, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000070#error "wrong value for __cpp_if_constexpr"
71#endif
72
Richard Smith38d91d42016-09-28 20:26:06 +000073// range_based_for checked below
74
Richard Smithb02043c2016-09-28 19:44:50 +000075// static_assert checked below
76
Richard Smith28ddb912018-11-14 21:04:34 +000077#if check(deduction_guides, 0, 0, 0, 201703, 201703)
Richard Smithadae25d2017-07-25 23:31:42 +000078#error "wrong value for __cpp_deduction_guides"
79#endif
80
Richard Smith28ddb912018-11-14 21:04:34 +000081#if check(nontype_template_parameter_auto, 0, 0, 0, 201606, 201606)
Richard Smith20eb9ba2018-06-14 00:40:20 +000082#error "wrong value for __cpp_nontype_template_parameter_auto"
83#endif
84
85// This is the old name (from P0096R4) for
86// __cpp_nontype_template_parameter_auto
Richard Smith28ddb912018-11-14 21:04:34 +000087#if check(template_auto, 0, 0, 0, 201606, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000088#error "wrong value for __cpp_template_auto"
89#endif
90
Richard Smith28ddb912018-11-14 21:04:34 +000091#if check(namespace_attributes, 0, 0, 0, 201411, 201411)
Richard Smithb02043c2016-09-28 19:44:50 +000092// FIXME: allowed without warning in C++14 and C++11
93#error "wrong value for __cpp_namespace_attributes"
94#endif
95
Richard Smith28ddb912018-11-14 21:04:34 +000096#if check(enumerator_attributes, 0, 0, 0, 201411, 201411)
Richard Smithb02043c2016-09-28 19:44:50 +000097// FIXME: allowed without warning in C++14 and C++11
98#error "wrong value for __cpp_enumerator_attributes"
99#endif
100
Richard Smith20eb9ba2018-06-14 00:40:20 +0000101// This is an old name (from P0096R4), now removed from SD-6.
Richard Smith28ddb912018-11-14 21:04:34 +0000102#if check(nested_namespace_definitions, 0, 0, 0, 201411, 201411)
Richard Smithb02043c2016-09-28 19:44:50 +0000103#error "wrong value for __cpp_nested_namespace_definitions"
104#endif
105
Richard Smithdbe74e02016-12-19 04:21:36 +0000106// inheriting_constructors checked below
107
Richard Smith28ddb912018-11-14 21:04:34 +0000108#if check(variadic_using, 0, 0, 0, 201611, 201611)
Richard Smithadae25d2017-07-25 23:31:42 +0000109#error "wrong value for __cpp_variadic_using"
110#endif
111
Richard Smith28ddb912018-11-14 21:04:34 +0000112#if check(aggregate_bases, 0, 0, 0, 201603, 201603)
Richard Smith38d91d42016-09-28 20:26:06 +0000113#error "wrong value for __cpp_aggregate_bases"
114#endif
115
Richard Smith28ddb912018-11-14 21:04:34 +0000116#if check(structured_bindings, 0, 0, 0, 201606, 201606)
Richard Smithdbe74e02016-12-19 04:21:36 +0000117#error "wrong value for __cpp_structured_bindings"
118#endif
Richard Smith6e4bedc2016-09-28 20:42:56 +0000119
Richard Smith28ddb912018-11-14 21:04:34 +0000120#if check(nontype_template_args, 0, 0, 0, 201411, 201411)
Richard Smithb02043c2016-09-28 19:44:50 +0000121#error "wrong value for __cpp_nontype_template_args"
122#endif
123
Richard Smith20eb9ba2018-06-14 00:40:20 +0000124#if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
Richard Smith28ddb912018-11-14 21:04:34 +0000125 ? check(template_template_args, 0, 0, 0, 201611, 201611) \
126 : check(template_template_args, 0, 0, 0, 0, 0)
Richard Smithcbe07932017-02-14 00:55:25 +0000127#error "wrong value for __cpp_template_template_args"
128#endif
129
Richard Smithb02043c2016-09-28 19:44:50 +0000130// --- C++14 features ---
131
Richard Smith28ddb912018-11-14 21:04:34 +0000132#if check(binary_literals, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000133#error "wrong value for __cpp_binary_literals"
134#endif
135
Richard Smithb02043c2016-09-28 19:44:50 +0000136// (Removed from SD-6.)
Richard Smith28ddb912018-11-14 21:04:34 +0000137#if check(digit_separators, 0, 0, 201309, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000138#error "wrong value for __cpp_digit_separators"
139#endif
140
Richard Smith28ddb912018-11-14 21:04:34 +0000141#if check(init_captures, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000142#error "wrong value for __cpp_init_captures"
143#endif
144
Richard Smith28ddb912018-11-14 21:04:34 +0000145#if check(generic_lambdas, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000146#error "wrong value for __cpp_generic_lambdas"
147#endif
148
Richard Smith28ddb912018-11-14 21:04:34 +0000149#if check(sized_deallocation, 0, 0, 201309, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000150#error "wrong value for __cpp_sized_deallocation"
151#endif
152
Richard Smithb02043c2016-09-28 19:44:50 +0000153// constexpr checked below
Richard Smith91e474f2013-11-27 22:58:16 +0000154
Richard Smith28ddb912018-11-14 21:04:34 +0000155#if check(decltype_auto, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000156#error "wrong value for __cpp_decltype_auto"
157#endif
158
Richard Smith28ddb912018-11-14 21:04:34 +0000159#if check(return_type_deduction, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000160#error "wrong value for __cpp_return_type_deduction"
161#endif
162
Richard Smith28ddb912018-11-14 21:04:34 +0000163#if check(runtime_arrays, 0, 0, 0, 0, 0)
Richard Smith91e474f2013-11-27 22:58:16 +0000164#error "wrong value for __cpp_runtime_arrays"
165#endif
166
Richard Smith28ddb912018-11-14 21:04:34 +0000167#if check(aggregate_nsdmi, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000168#error "wrong value for __cpp_aggregate_nsdmi"
169#endif
170
Richard Smith28ddb912018-11-14 21:04:34 +0000171#if check(variable_templates, 0, 0, 201304, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000172#error "wrong value for __cpp_variable_templates"
173#endif
174
Richard Smithb02043c2016-09-28 19:44:50 +0000175// --- C++11 features ---
176
Richard Smith28ddb912018-11-14 21:04:34 +0000177#if check(unicode_characters, 0, 200704, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000178#error "wrong value for __cpp_unicode_characters"
179#endif
180
Richard Smith28ddb912018-11-14 21:04:34 +0000181#if check(raw_strings, 0, 200710, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000182#error "wrong value for __cpp_raw_strings"
183#endif
184
Richard Smith28ddb912018-11-14 21:04:34 +0000185#if check(unicode_literals, 0, 200710, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000186#error "wrong value for __cpp_unicode_literals"
187#endif
188
Richard Smith28ddb912018-11-14 21:04:34 +0000189#if check(user_defined_literals, 0, 200809, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000190#error "wrong value for __cpp_user_defined_literals"
191#endif
192
Richard Smith28ddb912018-11-14 21:04:34 +0000193#if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0, 0) : \
194 check(threadsafe_static_init, 200806, 200806, 200806, 200806, 200806)
Richard Smith9d07ae72017-08-11 03:39:40 +0000195#error "wrong value for __cpp_threadsafe_static_init"
196#endif
197
Richard Smith28ddb912018-11-14 21:04:34 +0000198#if check(lambdas, 0, 200907, 200907, 200907, 200907)
Richard Smith91e474f2013-11-27 22:58:16 +0000199#error "wrong value for __cpp_lambdas"
200#endif
201
Richard Smith28ddb912018-11-14 21:04:34 +0000202#if check(constexpr, 0, 200704, 201304, 201603, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +0000203#error "wrong value for __cpp_constexpr"
204#endif
205
Richard Smith28ddb912018-11-14 21:04:34 +0000206#if check(range_based_for, 0, 200907, 200907, 201603, 201603)
Richard Smith38af8562014-11-12 21:16:38 +0000207#error "wrong value for __cpp_range_based_for"
208#endif
209
Richard Smith28ddb912018-11-14 21:04:34 +0000210#if check(static_assert, 0, 200410, 200410, 201411, 201411)
Richard Smith91e474f2013-11-27 22:58:16 +0000211#error "wrong value for __cpp_static_assert"
212#endif
213
Richard Smith28ddb912018-11-14 21:04:34 +0000214#if check(decltype, 0, 200707, 200707, 200707, 200707)
Richard Smith91e474f2013-11-27 22:58:16 +0000215#error "wrong value for __cpp_decltype"
216#endif
217
Richard Smith28ddb912018-11-14 21:04:34 +0000218#if check(attributes, 0, 200809, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000219#error "wrong value for __cpp_attributes"
220#endif
221
Richard Smith28ddb912018-11-14 21:04:34 +0000222#if check(rvalue_references, 0, 200610, 200610, 200610, 200610)
Richard Smith91e474f2013-11-27 22:58:16 +0000223#error "wrong value for __cpp_rvalue_references"
224#endif
225
Richard Smith28ddb912018-11-14 21:04:34 +0000226#if check(variadic_templates, 0, 200704, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000227#error "wrong value for __cpp_variadic_templates"
228#endif
Richard Smith38af8562014-11-12 21:16:38 +0000229
Richard Smith28ddb912018-11-14 21:04:34 +0000230#if check(initializer_lists, 0, 200806, 200806, 200806, 200806)
Richard Smith38af8562014-11-12 21:16:38 +0000231#error "wrong value for __cpp_initializer_lists"
232#endif
233
Richard Smith28ddb912018-11-14 21:04:34 +0000234#if check(delegating_constructors, 0, 200604, 200604, 200604, 200604)
Richard Smith38af8562014-11-12 21:16:38 +0000235#error "wrong value for __cpp_delegating_constructors"
236#endif
237
Richard Smith28ddb912018-11-14 21:04:34 +0000238#if check(nsdmi, 0, 200809, 200809, 200809, 200809)
Richard Smith38af8562014-11-12 21:16:38 +0000239#error "wrong value for __cpp_nsdmi"
240#endif
241
Richard Smith28ddb912018-11-14 21:04:34 +0000242#if check(inheriting_constructors, 0, 201511, 201511, 201511, 201511)
Richard Smith38af8562014-11-12 21:16:38 +0000243#error "wrong value for __cpp_inheriting_constructors"
244#endif
245
Richard Smith28ddb912018-11-14 21:04:34 +0000246#if check(ref_qualifiers, 0, 200710, 200710, 200710, 200710)
Richard Smith38af8562014-11-12 21:16:38 +0000247#error "wrong value for __cpp_ref_qualifiers"
248#endif
249
Richard Smith28ddb912018-11-14 21:04:34 +0000250#if check(alias_templates, 0, 200704, 200704, 200704, 200704)
Richard Smith38af8562014-11-12 21:16:38 +0000251#error "wrong value for __cpp_alias_templates"
252#endif
Faisal Vali24d59d12015-05-22 01:11:10 +0000253
Richard Smithb02043c2016-09-28 19:44:50 +0000254// --- C++98 features ---
255
Richard Smith28ddb912018-11-14 21:04:34 +0000256#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711, 199711)
Richard Smithb02043c2016-09-28 19:44:50 +0000257#error "wrong value for __cpp_rtti"
258#endif
259
Richard Smith28ddb912018-11-14 21:04:34 +0000260#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711, 199711)
Richard Smithb02043c2016-09-28 19:44:50 +0000261#error "wrong value for __cpp_exceptions"
262#endif
263
264// --- TS features --
265
Richard Smith28ddb912018-11-14 21:04:34 +0000266#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS, CONCEPTS_TS)
Faisal Vali24d59d12015-05-22 01:11:10 +0000267#error "wrong value for __cpp_experimental_concepts"
268#endif
Richard Smith3fa73f32015-10-22 04:27:47 +0000269
Richard Smith28ddb912018-11-14 21:04:34 +0000270#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0, 0)
Richard Smith3fa73f32015-10-22 04:27:47 +0000271#error "wrong value for __cpp_coroutines"
272#endif