blob: 772fa26e96fc177b22de11cd7c56137711353e05 [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 Smith91e474f2013-11-27 22:58:16 +000012
13// expected-no-diagnostics
14
Nico Weberb2348f42016-01-19 15:15:31 +000015// FIXME using `defined` in a macro has undefined behavior.
Richard Smith91e474f2013-11-27 22:58:16 +000016#if __cplusplus < 201103L
Richard Smith20eb9ba2018-06-14 00:40:20 +000017#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
JF Bastiene3c13a82016-03-22 21:12:48 +000018#elif __cplusplus < 201402L
Richard Smith20eb9ba2018-06-14 00:40:20 +000019#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
JF Bastiene3c13a82016-03-22 21:12:48 +000020#elif __cplusplus < 201406L
Richard Smith20eb9ba2018-06-14 00:40:20 +000021#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
Richard Smith91e474f2013-11-27 22:58:16 +000022#else
Richard Smith20eb9ba2018-06-14 00:40:20 +000023#define check(macro, cxx98, cxx11, cxx14, cxx17) cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17
Richard Smith91e474f2013-11-27 22:58:16 +000024#endif
25
Richard Smithb02043c2016-09-28 19:44:50 +000026// --- C++17 features ---
27
Richard Smith38d91d42016-09-28 20:26:06 +000028#if check(hex_float, 0, 0, 0, 201603)
29#error "wrong value for __cpp_hex_float"
30#endif
31
Richard Smith9d07ae72017-08-11 03:39:40 +000032#if check(inline_variables, 0, 0, 0, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000033#error "wrong value for __cpp_inline_variables"
34#endif
35
Richard Smith9d07ae72017-08-11 03:39:40 +000036#if check(aligned_new, 0, 0, 0, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000037#error "wrong value for __cpp_aligned_new"
38#endif
39
Richard Smith20eb9ba2018-06-14 00:40:20 +000040#if check(guaranteed_copy_elision, 0, 0, 0, 201606)
41#error "wrong value for __cpp_guaranteed_copy_elision"
42#endif
43
Richard Smith6cc02c22016-12-02 02:02:23 +000044#if check(noexcept_function_type, 0, 0, 0, 201510)
Richard Smithb02043c2016-09-28 19:44:50 +000045#error "wrong value for __cpp_noexcept_function_type"
46#endif
47
Richard Smith38d91d42016-09-28 20:26:06 +000048#if check(fold_expressions, 0, 0, 0, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +000049#error "wrong value for __cpp_fold_expressions"
50#endif
51
Richard Smith38d91d42016-09-28 20:26:06 +000052#if check(capture_star_this, 0, 0, 0, 201603)
53#error "wrong value for __cpp_capture_star_this"
54#endif
55
Richard Smithb80bbca2017-02-21 23:58:29 +000056// constexpr checked below
Richard Smith38d91d42016-09-28 20:26:06 +000057
Richard Smith9d07ae72017-08-11 03:39:40 +000058#if check(if_constexpr, 0, 0, 0, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000059#error "wrong value for __cpp_if_constexpr"
60#endif
61
Richard Smith38d91d42016-09-28 20:26:06 +000062// range_based_for checked below
63
Richard Smithb02043c2016-09-28 19:44:50 +000064// static_assert checked below
65
Richard Smith51055732018-05-30 19:54:52 +000066#if check(deduction_guides, 0, 0, 0, 201703)
Richard Smithadae25d2017-07-25 23:31:42 +000067#error "wrong value for __cpp_deduction_guides"
68#endif
69
Richard Smith20eb9ba2018-06-14 00:40:20 +000070#if check(nontype_template_parameter_auto, 0, 0, 0, 201606)
71#error "wrong value for __cpp_nontype_template_parameter_auto"
72#endif
73
74// This is the old name (from P0096R4) for
75// __cpp_nontype_template_parameter_auto
Richard Smith9d07ae72017-08-11 03:39:40 +000076#if check(template_auto, 0, 0, 0, 201606)
Richard Smith6e4bedc2016-09-28 20:42:56 +000077#error "wrong value for __cpp_template_auto"
78#endif
79
Richard Smithb02043c2016-09-28 19:44:50 +000080#if check(namespace_attributes, 0, 0, 0, 201411)
81// FIXME: allowed without warning in C++14 and C++11
82#error "wrong value for __cpp_namespace_attributes"
83#endif
84
85#if check(enumerator_attributes, 0, 0, 0, 201411)
86// FIXME: allowed without warning in C++14 and C++11
87#error "wrong value for __cpp_enumerator_attributes"
88#endif
89
Richard Smith20eb9ba2018-06-14 00:40:20 +000090// This is an old name (from P0096R4), now removed from SD-6.
Richard Smithb02043c2016-09-28 19:44:50 +000091#if check(nested_namespace_definitions, 0, 0, 0, 201411)
92#error "wrong value for __cpp_nested_namespace_definitions"
93#endif
94
Richard Smithdbe74e02016-12-19 04:21:36 +000095// inheriting_constructors checked below
96
Richard Smith9d07ae72017-08-11 03:39:40 +000097#if check(variadic_using, 0, 0, 0, 201611)
Richard Smithadae25d2017-07-25 23:31:42 +000098#error "wrong value for __cpp_variadic_using"
99#endif
100
Richard Smith38d91d42016-09-28 20:26:06 +0000101#if check(aggregate_bases, 0, 0, 0, 201603)
102#error "wrong value for __cpp_aggregate_bases"
103#endif
104
Richard Smithdbe74e02016-12-19 04:21:36 +0000105#if check(structured_bindings, 0, 0, 0, 201606)
106#error "wrong value for __cpp_structured_bindings"
107#endif
Richard Smith6e4bedc2016-09-28 20:42:56 +0000108
Richard Smithb02043c2016-09-28 19:44:50 +0000109#if check(nontype_template_args, 0, 0, 0, 201411)
110#error "wrong value for __cpp_nontype_template_args"
111#endif
112
Richard Smith20eb9ba2018-06-14 00:40:20 +0000113#if defined(RELAXED_TEMPLATE_TEMPLATE_ARGS) \
114 ? check(template_template_args, 0, 0, 0, 201611) \
115 : check(template_template_args, 0, 0, 0, 0)
Richard Smithcbe07932017-02-14 00:55:25 +0000116#error "wrong value for __cpp_template_template_args"
117#endif
118
Richard Smithb02043c2016-09-28 19:44:50 +0000119// --- C++14 features ---
120
JF Bastiene3c13a82016-03-22 21:12:48 +0000121#if check(binary_literals, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000122#error "wrong value for __cpp_binary_literals"
123#endif
124
Richard Smithb02043c2016-09-28 19:44:50 +0000125// (Removed from SD-6.)
JF Bastiene3c13a82016-03-22 21:12:48 +0000126#if check(digit_separators, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000127#error "wrong value for __cpp_digit_separators"
128#endif
129
JF Bastiene3c13a82016-03-22 21:12:48 +0000130#if check(init_captures, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000131#error "wrong value for __cpp_init_captures"
132#endif
133
JF Bastiene3c13a82016-03-22 21:12:48 +0000134#if check(generic_lambdas, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000135#error "wrong value for __cpp_generic_lambdas"
136#endif
137
JF Bastiene3c13a82016-03-22 21:12:48 +0000138#if check(sized_deallocation, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000139#error "wrong value for __cpp_sized_deallocation"
140#endif
141
Richard Smithb02043c2016-09-28 19:44:50 +0000142// constexpr checked below
Richard Smith91e474f2013-11-27 22:58:16 +0000143
JF Bastiene3c13a82016-03-22 21:12:48 +0000144#if check(decltype_auto, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000145#error "wrong value for __cpp_decltype_auto"
146#endif
147
JF Bastiene3c13a82016-03-22 21:12:48 +0000148#if check(return_type_deduction, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000149#error "wrong value for __cpp_return_type_deduction"
150#endif
151
JF Bastiene3c13a82016-03-22 21:12:48 +0000152#if check(runtime_arrays, 0, 0, 0, 0)
Richard Smith91e474f2013-11-27 22:58:16 +0000153#error "wrong value for __cpp_runtime_arrays"
154#endif
155
JF Bastiene3c13a82016-03-22 21:12:48 +0000156#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000157#error "wrong value for __cpp_aggregate_nsdmi"
158#endif
159
JF Bastiene3c13a82016-03-22 21:12:48 +0000160#if check(variable_templates, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000161#error "wrong value for __cpp_variable_templates"
162#endif
163
Richard Smithb02043c2016-09-28 19:44:50 +0000164// --- C++11 features ---
165
JF Bastiene3c13a82016-03-22 21:12:48 +0000166#if check(unicode_characters, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000167#error "wrong value for __cpp_unicode_characters"
168#endif
169
JF Bastiene3c13a82016-03-22 21:12:48 +0000170#if check(raw_strings, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000171#error "wrong value for __cpp_raw_strings"
172#endif
173
JF Bastiene3c13a82016-03-22 21:12:48 +0000174#if check(unicode_literals, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000175#error "wrong value for __cpp_unicode_literals"
176#endif
177
JF Bastiene3c13a82016-03-22 21:12:48 +0000178#if check(user_defined_literals, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000179#error "wrong value for __cpp_user_defined_literals"
180#endif
181
Richard Smith9d07ae72017-08-11 03:39:40 +0000182#if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0) : check(threadsafe_static_init, 200806, 200806, 200806, 200806)
183#error "wrong value for __cpp_threadsafe_static_init"
184#endif
185
JF Bastiene3c13a82016-03-22 21:12:48 +0000186#if check(lambdas, 0, 200907, 200907, 200907)
Richard Smith91e474f2013-11-27 22:58:16 +0000187#error "wrong value for __cpp_lambdas"
188#endif
189
Richard Smithb80bbca2017-02-21 23:58:29 +0000190#if check(constexpr, 0, 200704, 201304, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +0000191#error "wrong value for __cpp_constexpr"
192#endif
193
Richard Smith38d91d42016-09-28 20:26:06 +0000194#if check(range_based_for, 0, 200907, 200907, 201603)
Richard Smith38af8562014-11-12 21:16:38 +0000195#error "wrong value for __cpp_range_based_for"
196#endif
197
Richard Smithb02043c2016-09-28 19:44:50 +0000198#if check(static_assert, 0, 200410, 200410, 201411)
Richard Smith91e474f2013-11-27 22:58:16 +0000199#error "wrong value for __cpp_static_assert"
200#endif
201
JF Bastiene3c13a82016-03-22 21:12:48 +0000202#if check(decltype, 0, 200707, 200707, 200707)
Richard Smith91e474f2013-11-27 22:58:16 +0000203#error "wrong value for __cpp_decltype"
204#endif
205
JF Bastiene3c13a82016-03-22 21:12:48 +0000206#if check(attributes, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000207#error "wrong value for __cpp_attributes"
208#endif
209
JF Bastiene3c13a82016-03-22 21:12:48 +0000210#if check(rvalue_references, 0, 200610, 200610, 200610)
Richard Smith91e474f2013-11-27 22:58:16 +0000211#error "wrong value for __cpp_rvalue_references"
212#endif
213
JF Bastiene3c13a82016-03-22 21:12:48 +0000214#if check(variadic_templates, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000215#error "wrong value for __cpp_variadic_templates"
216#endif
Richard Smith38af8562014-11-12 21:16:38 +0000217
JF Bastiene3c13a82016-03-22 21:12:48 +0000218#if check(initializer_lists, 0, 200806, 200806, 200806)
Richard Smith38af8562014-11-12 21:16:38 +0000219#error "wrong value for __cpp_initializer_lists"
220#endif
221
JF Bastiene3c13a82016-03-22 21:12:48 +0000222#if check(delegating_constructors, 0, 200604, 200604, 200604)
Richard Smith38af8562014-11-12 21:16:38 +0000223#error "wrong value for __cpp_delegating_constructors"
224#endif
225
JF Bastiene3c13a82016-03-22 21:12:48 +0000226#if check(nsdmi, 0, 200809, 200809, 200809)
Richard Smith38af8562014-11-12 21:16:38 +0000227#error "wrong value for __cpp_nsdmi"
228#endif
229
Richard Smithb02043c2016-09-28 19:44:50 +0000230#if check(inheriting_constructors, 0, 201511, 201511, 201511)
Richard Smith38af8562014-11-12 21:16:38 +0000231#error "wrong value for __cpp_inheriting_constructors"
232#endif
233
JF Bastiene3c13a82016-03-22 21:12:48 +0000234#if check(ref_qualifiers, 0, 200710, 200710, 200710)
Richard Smith38af8562014-11-12 21:16:38 +0000235#error "wrong value for __cpp_ref_qualifiers"
236#endif
237
JF Bastiene3c13a82016-03-22 21:12:48 +0000238#if check(alias_templates, 0, 200704, 200704, 200704)
Richard Smith38af8562014-11-12 21:16:38 +0000239#error "wrong value for __cpp_alias_templates"
240#endif
Faisal Vali24d59d12015-05-22 01:11:10 +0000241
Richard Smithb02043c2016-09-28 19:44:50 +0000242// --- C++98 features ---
243
244#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
245#error "wrong value for __cpp_rtti"
246#endif
247
248#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
249#error "wrong value for __cpp_exceptions"
250#endif
251
252// --- TS features --
253
JF Bastiene3c13a82016-03-22 21:12:48 +0000254#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
Faisal Vali24d59d12015-05-22 01:11:10 +0000255#error "wrong value for __cpp_experimental_concepts"
256#endif
Richard Smith3fa73f32015-10-22 04:27:47 +0000257
Eric Fiselier4bf92822017-05-25 14:58:46 +0000258#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0)
Richard Smith3fa73f32015-10-22 04:27:47 +0000259#error "wrong value for __cpp_coroutines"
260#endif
Richard Smith3a8244d2018-05-01 05:02:45 +0000261
262// --- not-yet-standard features --
263
264#if defined(CHAR8_T) ? check(char8_t, 201803, 201803, 201803, 201803) : check(char8_t, 0, 0, 0, 0)
265#error "wrong value for __cpp_char8_t"
266#endif