blob: e9a514db758b173017cbbf1d006a69cb5a03fd07 [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
Gor Nishanov4ffb4342016-10-02 03:31:58 +00008// RUN: %clang_cc1 -fcoroutines-ts -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
Richard Smithf5d8a752016-10-10 06:55:42 +000033#if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name
Richard Smith6e4bedc2016-09-28 20:42:56 +000034#error "wrong value for __cpp_aligned_new"
35#endif
36
Richard Smith6cc02c22016-12-02 02:02:23 +000037#if check(noexcept_function_type, 0, 0, 0, 201510)
Richard Smithb02043c2016-09-28 19:44:50 +000038#error "wrong value for __cpp_noexcept_function_type"
39#endif
40
Richard Smith38d91d42016-09-28 20:26:06 +000041#if check(fold_expressions, 0, 0, 0, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +000042#error "wrong value for __cpp_fold_expressions"
43#endif
44
Richard Smith38d91d42016-09-28 20:26:06 +000045#if check(capture_star_this, 0, 0, 0, 201603)
46#error "wrong value for __cpp_capture_star_this"
47#endif
48
Richard Smithb80bbca2017-02-21 23:58:29 +000049// constexpr checked below
Richard Smith38d91d42016-09-28 20:26:06 +000050
Richard Smith6e4bedc2016-09-28 20:42:56 +000051#if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
52#error "wrong value for __cpp_if_constexpr"
53#endif
54
Richard Smith38d91d42016-09-28 20:26:06 +000055// range_based_for checked below
56
Richard Smithb02043c2016-09-28 19:44:50 +000057// static_assert checked below
58
Richard Smithadae25d2017-07-25 23:31:42 +000059#if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
60#error "wrong value for __cpp_deduction_guides"
61#endif
62
Richard Smith27143d82016-09-29 00:08:05 +000063#if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
Richard Smith6e4bedc2016-09-28 20:42:56 +000064#error "wrong value for __cpp_template_auto"
65#endif
66
Richard Smithb02043c2016-09-28 19:44:50 +000067#if check(namespace_attributes, 0, 0, 0, 201411)
68// FIXME: allowed without warning in C++14 and C++11
69#error "wrong value for __cpp_namespace_attributes"
70#endif
71
72#if check(enumerator_attributes, 0, 0, 0, 201411)
73// FIXME: allowed without warning in C++14 and C++11
74#error "wrong value for __cpp_enumerator_attributes"
75#endif
76
77#if check(nested_namespace_definitions, 0, 0, 0, 201411)
78#error "wrong value for __cpp_nested_namespace_definitions"
79#endif
80
Richard Smithdbe74e02016-12-19 04:21:36 +000081// inheriting_constructors checked below
82
Richard Smithadae25d2017-07-25 23:31:42 +000083#if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
84#error "wrong value for __cpp_variadic_using"
85#endif
86
Richard Smith38d91d42016-09-28 20:26:06 +000087#if check(aggregate_bases, 0, 0, 0, 201603)
88#error "wrong value for __cpp_aggregate_bases"
89#endif
90
Richard Smithdbe74e02016-12-19 04:21:36 +000091#if check(structured_bindings, 0, 0, 0, 201606)
92#error "wrong value for __cpp_structured_bindings"
93#endif
Richard Smith6e4bedc2016-09-28 20:42:56 +000094
Richard Smithb02043c2016-09-28 19:44:50 +000095#if check(nontype_template_args, 0, 0, 0, 201411)
96#error "wrong value for __cpp_nontype_template_args"
97#endif
98
Richard Smithcbe07932017-02-14 00:55:25 +000099#if check(template_template_args, 0, 0, 0, 0) // FIXME: should be 201611 when feature is enabled
100#error "wrong value for __cpp_template_template_args"
101#endif
102
Richard Smithb02043c2016-09-28 19:44:50 +0000103// --- C++14 features ---
104
JF Bastiene3c13a82016-03-22 21:12:48 +0000105#if check(binary_literals, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000106#error "wrong value for __cpp_binary_literals"
107#endif
108
Richard Smithb02043c2016-09-28 19:44:50 +0000109// (Removed from SD-6.)
JF Bastiene3c13a82016-03-22 21:12:48 +0000110#if check(digit_separators, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000111#error "wrong value for __cpp_digit_separators"
112#endif
113
JF Bastiene3c13a82016-03-22 21:12:48 +0000114#if check(init_captures, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000115#error "wrong value for __cpp_init_captures"
116#endif
117
JF Bastiene3c13a82016-03-22 21:12:48 +0000118#if check(generic_lambdas, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000119#error "wrong value for __cpp_generic_lambdas"
120#endif
121
JF Bastiene3c13a82016-03-22 21:12:48 +0000122#if check(sized_deallocation, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +0000123#error "wrong value for __cpp_sized_deallocation"
124#endif
125
Richard Smithb02043c2016-09-28 19:44:50 +0000126// constexpr checked below
Richard Smith91e474f2013-11-27 22:58:16 +0000127
JF Bastiene3c13a82016-03-22 21:12:48 +0000128#if check(decltype_auto, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000129#error "wrong value for __cpp_decltype_auto"
130#endif
131
JF Bastiene3c13a82016-03-22 21:12:48 +0000132#if check(return_type_deduction, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000133#error "wrong value for __cpp_return_type_deduction"
134#endif
135
JF Bastiene3c13a82016-03-22 21:12:48 +0000136#if check(runtime_arrays, 0, 0, 0, 0)
Richard Smith91e474f2013-11-27 22:58:16 +0000137#error "wrong value for __cpp_runtime_arrays"
138#endif
139
JF Bastiene3c13a82016-03-22 21:12:48 +0000140#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000141#error "wrong value for __cpp_aggregate_nsdmi"
142#endif
143
JF Bastiene3c13a82016-03-22 21:12:48 +0000144#if check(variable_templates, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000145#error "wrong value for __cpp_variable_templates"
146#endif
147
Richard Smithb02043c2016-09-28 19:44:50 +0000148// --- C++11 features ---
149
JF Bastiene3c13a82016-03-22 21:12:48 +0000150#if check(unicode_characters, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000151#error "wrong value for __cpp_unicode_characters"
152#endif
153
JF Bastiene3c13a82016-03-22 21:12:48 +0000154#if check(raw_strings, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000155#error "wrong value for __cpp_raw_strings"
156#endif
157
JF Bastiene3c13a82016-03-22 21:12:48 +0000158#if check(unicode_literals, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000159#error "wrong value for __cpp_unicode_literals"
160#endif
161
JF Bastiene3c13a82016-03-22 21:12:48 +0000162#if check(user_defined_literals, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000163#error "wrong value for __cpp_user_defined_literals"
164#endif
165
JF Bastiene3c13a82016-03-22 21:12:48 +0000166#if check(lambdas, 0, 200907, 200907, 200907)
Richard Smith91e474f2013-11-27 22:58:16 +0000167#error "wrong value for __cpp_lambdas"
168#endif
169
Richard Smithb80bbca2017-02-21 23:58:29 +0000170#if check(constexpr, 0, 200704, 201304, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +0000171#error "wrong value for __cpp_constexpr"
172#endif
173
Richard Smith38d91d42016-09-28 20:26:06 +0000174#if check(range_based_for, 0, 200907, 200907, 201603)
Richard Smith38af8562014-11-12 21:16:38 +0000175#error "wrong value for __cpp_range_based_for"
176#endif
177
Richard Smithb02043c2016-09-28 19:44:50 +0000178#if check(static_assert, 0, 200410, 200410, 201411)
Richard Smith91e474f2013-11-27 22:58:16 +0000179#error "wrong value for __cpp_static_assert"
180#endif
181
JF Bastiene3c13a82016-03-22 21:12:48 +0000182#if check(decltype, 0, 200707, 200707, 200707)
Richard Smith91e474f2013-11-27 22:58:16 +0000183#error "wrong value for __cpp_decltype"
184#endif
185
JF Bastiene3c13a82016-03-22 21:12:48 +0000186#if check(attributes, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000187#error "wrong value for __cpp_attributes"
188#endif
189
JF Bastiene3c13a82016-03-22 21:12:48 +0000190#if check(rvalue_references, 0, 200610, 200610, 200610)
Richard Smith91e474f2013-11-27 22:58:16 +0000191#error "wrong value for __cpp_rvalue_references"
192#endif
193
JF Bastiene3c13a82016-03-22 21:12:48 +0000194#if check(variadic_templates, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000195#error "wrong value for __cpp_variadic_templates"
196#endif
Richard Smith38af8562014-11-12 21:16:38 +0000197
JF Bastiene3c13a82016-03-22 21:12:48 +0000198#if check(initializer_lists, 0, 200806, 200806, 200806)
Richard Smith38af8562014-11-12 21:16:38 +0000199#error "wrong value for __cpp_initializer_lists"
200#endif
201
JF Bastiene3c13a82016-03-22 21:12:48 +0000202#if check(delegating_constructors, 0, 200604, 200604, 200604)
Richard Smith38af8562014-11-12 21:16:38 +0000203#error "wrong value for __cpp_delegating_constructors"
204#endif
205
JF Bastiene3c13a82016-03-22 21:12:48 +0000206#if check(nsdmi, 0, 200809, 200809, 200809)
Richard Smith38af8562014-11-12 21:16:38 +0000207#error "wrong value for __cpp_nsdmi"
208#endif
209
Richard Smithb02043c2016-09-28 19:44:50 +0000210#if check(inheriting_constructors, 0, 201511, 201511, 201511)
Richard Smith38af8562014-11-12 21:16:38 +0000211#error "wrong value for __cpp_inheriting_constructors"
212#endif
213
JF Bastiene3c13a82016-03-22 21:12:48 +0000214#if check(ref_qualifiers, 0, 200710, 200710, 200710)
Richard Smith38af8562014-11-12 21:16:38 +0000215#error "wrong value for __cpp_ref_qualifiers"
216#endif
217
JF Bastiene3c13a82016-03-22 21:12:48 +0000218#if check(alias_templates, 0, 200704, 200704, 200704)
Richard Smith38af8562014-11-12 21:16:38 +0000219#error "wrong value for __cpp_alias_templates"
220#endif
Faisal Vali24d59d12015-05-22 01:11:10 +0000221
Richard Smithb02043c2016-09-28 19:44:50 +0000222// --- C++98 features ---
223
224#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
225#error "wrong value for __cpp_rtti"
226#endif
227
228#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
229#error "wrong value for __cpp_exceptions"
230#endif
231
232// --- TS features --
233
JF Bastiene3c13a82016-03-22 21:12:48 +0000234#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
Faisal Vali24d59d12015-05-22 01:11:10 +0000235#error "wrong value for __cpp_experimental_concepts"
236#endif
Richard Smith3fa73f32015-10-22 04:27:47 +0000237
Eric Fiselier4bf92822017-05-25 14:58:46 +0000238#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0)
Richard Smith3fa73f32015-10-22 04:27:47 +0000239#error "wrong value for __cpp_coroutines"
240#endif