blob: 18fdaa5dda3e1d5b74410bb76300cd3664b129e7 [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 Smithb02043c2016-09-28 19:44:50 +000029#if check(noexcept_function_type, 0, 0, 0, 0)
Richard Smith38d91d42016-09-28 20:26:06 +000030// FIXME: value shuld be 201510 for cxx1z once implemented
Richard Smithb02043c2016-09-28 19:44:50 +000031#error "wrong value for __cpp_noexcept_function_type"
32#endif
33
Richard Smith38d91d42016-09-28 20:26:06 +000034#if check(fold_expressions, 0, 0, 0, 201603)
Richard Smithb02043c2016-09-28 19:44:50 +000035#error "wrong value for __cpp_fold_expressions"
36#endif
37
Richard Smith38d91d42016-09-28 20:26:06 +000038#if check(capture_star_this, 0, 0, 0, 201603)
39#error "wrong value for __cpp_capture_star_this"
40#endif
41
42// FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support
43
44// range_based_for checked below
45
Richard Smithb02043c2016-09-28 19:44:50 +000046// static_assert checked below
47
48#if check(namespace_attributes, 0, 0, 0, 201411)
49// FIXME: allowed without warning in C++14 and C++11
50#error "wrong value for __cpp_namespace_attributes"
51#endif
52
53#if check(enumerator_attributes, 0, 0, 0, 201411)
54// FIXME: allowed without warning in C++14 and C++11
55#error "wrong value for __cpp_enumerator_attributes"
56#endif
57
58#if check(nested_namespace_definitions, 0, 0, 0, 201411)
59#error "wrong value for __cpp_nested_namespace_definitions"
60#endif
61
Richard Smith38d91d42016-09-28 20:26:06 +000062#if check(aggregate_bases, 0, 0, 0, 201603)
63#error "wrong value for __cpp_aggregate_bases"
64#endif
65
Richard Smithb02043c2016-09-28 19:44:50 +000066#if check(nontype_template_args, 0, 0, 0, 201411)
67#error "wrong value for __cpp_nontype_template_args"
68#endif
69
70// --- C++14 features ---
71
JF Bastiene3c13a82016-03-22 21:12:48 +000072#if check(binary_literals, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +000073#error "wrong value for __cpp_binary_literals"
74#endif
75
Richard Smithb02043c2016-09-28 19:44:50 +000076// (Removed from SD-6.)
JF Bastiene3c13a82016-03-22 21:12:48 +000077#if check(digit_separators, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +000078#error "wrong value for __cpp_digit_separators"
79#endif
80
JF Bastiene3c13a82016-03-22 21:12:48 +000081#if check(init_captures, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +000082#error "wrong value for __cpp_init_captures"
83#endif
84
JF Bastiene3c13a82016-03-22 21:12:48 +000085#if check(generic_lambdas, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +000086#error "wrong value for __cpp_generic_lambdas"
87#endif
88
JF Bastiene3c13a82016-03-22 21:12:48 +000089#if check(sized_deallocation, 0, 0, 201309, 201309)
Richard Smith38af8562014-11-12 21:16:38 +000090#error "wrong value for __cpp_sized_deallocation"
91#endif
92
Richard Smithb02043c2016-09-28 19:44:50 +000093// constexpr checked below
Richard Smith91e474f2013-11-27 22:58:16 +000094
JF Bastiene3c13a82016-03-22 21:12:48 +000095#if check(decltype_auto, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +000096#error "wrong value for __cpp_decltype_auto"
97#endif
98
JF Bastiene3c13a82016-03-22 21:12:48 +000099#if check(return_type_deduction, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000100#error "wrong value for __cpp_return_type_deduction"
101#endif
102
JF Bastiene3c13a82016-03-22 21:12:48 +0000103#if check(runtime_arrays, 0, 0, 0, 0)
Richard Smith91e474f2013-11-27 22:58:16 +0000104#error "wrong value for __cpp_runtime_arrays"
105#endif
106
JF Bastiene3c13a82016-03-22 21:12:48 +0000107#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000108#error "wrong value for __cpp_aggregate_nsdmi"
109#endif
110
JF Bastiene3c13a82016-03-22 21:12:48 +0000111#if check(variable_templates, 0, 0, 201304, 201304)
Richard Smith91e474f2013-11-27 22:58:16 +0000112#error "wrong value for __cpp_variable_templates"
113#endif
114
Richard Smithb02043c2016-09-28 19:44:50 +0000115// --- C++11 features ---
116
JF Bastiene3c13a82016-03-22 21:12:48 +0000117#if check(unicode_characters, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000118#error "wrong value for __cpp_unicode_characters"
119#endif
120
JF Bastiene3c13a82016-03-22 21:12:48 +0000121#if check(raw_strings, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000122#error "wrong value for __cpp_raw_strings"
123#endif
124
JF Bastiene3c13a82016-03-22 21:12:48 +0000125#if check(unicode_literals, 0, 200710, 200710, 200710)
Richard Smith91e474f2013-11-27 22:58:16 +0000126#error "wrong value for __cpp_unicode_literals"
127#endif
128
JF Bastiene3c13a82016-03-22 21:12:48 +0000129#if check(user_defined_literals, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000130#error "wrong value for __cpp_user_defined_literals"
131#endif
132
JF Bastiene3c13a82016-03-22 21:12:48 +0000133#if check(lambdas, 0, 200907, 200907, 200907)
Richard Smith91e474f2013-11-27 22:58:16 +0000134#error "wrong value for __cpp_lambdas"
135#endif
136
Richard Smithb02043c2016-09-28 19:44:50 +0000137#if check(constexpr, 0, 200704, 201304, 201304)
138#error "wrong value for __cpp_constexpr"
139#endif
140
Richard Smith38d91d42016-09-28 20:26:06 +0000141#if check(range_based_for, 0, 200907, 200907, 201603)
Richard Smith38af8562014-11-12 21:16:38 +0000142#error "wrong value for __cpp_range_based_for"
143#endif
144
Richard Smithb02043c2016-09-28 19:44:50 +0000145#if check(static_assert, 0, 200410, 200410, 201411)
Richard Smith91e474f2013-11-27 22:58:16 +0000146#error "wrong value for __cpp_static_assert"
147#endif
148
JF Bastiene3c13a82016-03-22 21:12:48 +0000149#if check(decltype, 0, 200707, 200707, 200707)
Richard Smith91e474f2013-11-27 22:58:16 +0000150#error "wrong value for __cpp_decltype"
151#endif
152
JF Bastiene3c13a82016-03-22 21:12:48 +0000153#if check(attributes, 0, 200809, 200809, 200809)
Richard Smith91e474f2013-11-27 22:58:16 +0000154#error "wrong value for __cpp_attributes"
155#endif
156
JF Bastiene3c13a82016-03-22 21:12:48 +0000157#if check(rvalue_references, 0, 200610, 200610, 200610)
Richard Smith91e474f2013-11-27 22:58:16 +0000158#error "wrong value for __cpp_rvalue_references"
159#endif
160
JF Bastiene3c13a82016-03-22 21:12:48 +0000161#if check(variadic_templates, 0, 200704, 200704, 200704)
Richard Smith91e474f2013-11-27 22:58:16 +0000162#error "wrong value for __cpp_variadic_templates"
163#endif
Richard Smith38af8562014-11-12 21:16:38 +0000164
JF Bastiene3c13a82016-03-22 21:12:48 +0000165#if check(initializer_lists, 0, 200806, 200806, 200806)
Richard Smith38af8562014-11-12 21:16:38 +0000166#error "wrong value for __cpp_initializer_lists"
167#endif
168
JF Bastiene3c13a82016-03-22 21:12:48 +0000169#if check(delegating_constructors, 0, 200604, 200604, 200604)
Richard Smith38af8562014-11-12 21:16:38 +0000170#error "wrong value for __cpp_delegating_constructors"
171#endif
172
JF Bastiene3c13a82016-03-22 21:12:48 +0000173#if check(nsdmi, 0, 200809, 200809, 200809)
Richard Smith38af8562014-11-12 21:16:38 +0000174#error "wrong value for __cpp_nsdmi"
175#endif
176
Richard Smithb02043c2016-09-28 19:44:50 +0000177#if check(inheriting_constructors, 0, 201511, 201511, 201511)
Richard Smith38af8562014-11-12 21:16:38 +0000178#error "wrong value for __cpp_inheriting_constructors"
179#endif
180
JF Bastiene3c13a82016-03-22 21:12:48 +0000181#if check(ref_qualifiers, 0, 200710, 200710, 200710)
Richard Smith38af8562014-11-12 21:16:38 +0000182#error "wrong value for __cpp_ref_qualifiers"
183#endif
184
JF Bastiene3c13a82016-03-22 21:12:48 +0000185#if check(alias_templates, 0, 200704, 200704, 200704)
Richard Smith38af8562014-11-12 21:16:38 +0000186#error "wrong value for __cpp_alias_templates"
187#endif
Faisal Vali24d59d12015-05-22 01:11:10 +0000188
Richard Smithb02043c2016-09-28 19:44:50 +0000189// --- C++98 features ---
190
191#if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
192#error "wrong value for __cpp_rtti"
193#endif
194
195#if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
196#error "wrong value for __cpp_exceptions"
197#endif
198
199// --- TS features --
200
JF Bastiene3c13a82016-03-22 21:12:48 +0000201#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
Faisal Vali24d59d12015-05-22 01:11:10 +0000202#error "wrong value for __cpp_experimental_concepts"
203#endif
Richard Smith3fa73f32015-10-22 04:27:47 +0000204
205#if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
206#error "wrong value for __cpp_coroutines"
207#endif