1 // 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-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s
9 
10 // expected-no-diagnostics
11 
12 // FIXME using `defined` in a macro has undefined behavior.
13 #if __cplusplus < 201103L
14 #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
19 #else
20 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
21 #endif
22 
23 // --- C++17 features ---
24 
25 #if check(hex_float, 0, 0, 0, 201603)
26 #error "wrong value for __cpp_hex_float"
27 #endif
28 
29 #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, 201606) // FIXME: provisional name
34 #error "wrong value for __cpp_aligned_new"
35 #endif
36 
37 #if check(noexcept_function_type, 0, 0, 0, 0)
38 // FIXME: value shuld be 201510 for cxx1z once implemented
39 #error "wrong value for __cpp_noexcept_function_type"
40 #endif
41 
42 #if check(fold_expressions, 0, 0, 0, 201603)
43 #error "wrong value for __cpp_fold_expressions"
44 #endif
45 
46 #if check(capture_star_this, 0, 0, 0, 201603)
47 #error "wrong value for __cpp_capture_star_this"
48 #endif
49 
50 // FIXME: bump __cpp_constexpr to 201603 for constexpr lambda support
51 
52 #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
53 #error "wrong value for __cpp_if_constexpr"
54 #endif
55 
56 // range_based_for checked below
57 
58 // static_assert checked below
59 
60 #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
61 #error "wrong value for __cpp_template_auto"
62 #endif
63 
64 #if check(namespace_attributes, 0, 0, 0, 201411)
65 // FIXME: allowed without warning in C++14 and C++11
66 #error "wrong value for __cpp_namespace_attributes"
67 #endif
68 
69 #if check(enumerator_attributes, 0, 0, 0, 201411)
70 // FIXME: allowed without warning in C++14 and C++11
71 #error "wrong value for __cpp_enumerator_attributes"
72 #endif
73 
74 #if check(nested_namespace_definitions, 0, 0, 0, 201411)
75 #error "wrong value for __cpp_nested_namespace_definitions"
76 #endif
77 
78 #if check(aggregate_bases, 0, 0, 0, 201603)
79 #error "wrong value for __cpp_aggregate_bases"
80 #endif
81 
82 // FIXME: structured_bindings / decomposition_decl name not yet settled, and
83 // Clang implementation is incomplete.
84 
85 #if check(nontype_template_args, 0, 0, 0, 201411)
86 #error "wrong value for __cpp_nontype_template_args"
87 #endif
88 
89 // --- C++14 features ---
90 
91 #if check(binary_literals, 0, 0, 201304, 201304)
92 #error "wrong value for __cpp_binary_literals"
93 #endif
94 
95 // (Removed from SD-6.)
96 #if check(digit_separators, 0, 0, 201309, 201309)
97 #error "wrong value for __cpp_digit_separators"
98 #endif
99 
100 #if check(init_captures, 0, 0, 201304, 201304)
101 #error "wrong value for __cpp_init_captures"
102 #endif
103 
104 #if check(generic_lambdas, 0, 0, 201304, 201304)
105 #error "wrong value for __cpp_generic_lambdas"
106 #endif
107 
108 #if check(sized_deallocation, 0, 0, 201309, 201309)
109 #error "wrong value for __cpp_sized_deallocation"
110 #endif
111 
112 // constexpr checked below
113 
114 #if check(decltype_auto, 0, 0, 201304, 201304)
115 #error "wrong value for __cpp_decltype_auto"
116 #endif
117 
118 #if check(return_type_deduction, 0, 0, 201304, 201304)
119 #error "wrong value for __cpp_return_type_deduction"
120 #endif
121 
122 #if check(runtime_arrays, 0, 0, 0, 0)
123 #error "wrong value for __cpp_runtime_arrays"
124 #endif
125 
126 #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
127 #error "wrong value for __cpp_aggregate_nsdmi"
128 #endif
129 
130 #if check(variable_templates, 0, 0, 201304, 201304)
131 #error "wrong value for __cpp_variable_templates"
132 #endif
133 
134 // --- C++11 features ---
135 
136 #if check(unicode_characters, 0, 200704, 200704, 200704)
137 #error "wrong value for __cpp_unicode_characters"
138 #endif
139 
140 #if check(raw_strings, 0, 200710, 200710, 200710)
141 #error "wrong value for __cpp_raw_strings"
142 #endif
143 
144 #if check(unicode_literals, 0, 200710, 200710, 200710)
145 #error "wrong value for __cpp_unicode_literals"
146 #endif
147 
148 #if check(user_defined_literals, 0, 200809, 200809, 200809)
149 #error "wrong value for __cpp_user_defined_literals"
150 #endif
151 
152 #if check(lambdas, 0, 200907, 200907, 200907)
153 #error "wrong value for __cpp_lambdas"
154 #endif
155 
156 #if check(constexpr, 0, 200704, 201304, 201304)
157 #error "wrong value for __cpp_constexpr"
158 #endif
159 
160 #if check(range_based_for, 0, 200907, 200907, 201603)
161 #error "wrong value for __cpp_range_based_for"
162 #endif
163 
164 #if check(static_assert, 0, 200410, 200410, 201411)
165 #error "wrong value for __cpp_static_assert"
166 #endif
167 
168 #if check(decltype, 0, 200707, 200707, 200707)
169 #error "wrong value for __cpp_decltype"
170 #endif
171 
172 #if check(attributes, 0, 200809, 200809, 200809)
173 #error "wrong value for __cpp_attributes"
174 #endif
175 
176 #if check(rvalue_references, 0, 200610, 200610, 200610)
177 #error "wrong value for __cpp_rvalue_references"
178 #endif
179 
180 #if check(variadic_templates, 0, 200704, 200704, 200704)
181 #error "wrong value for __cpp_variadic_templates"
182 #endif
183 
184 #if check(initializer_lists, 0, 200806, 200806, 200806)
185 #error "wrong value for __cpp_initializer_lists"
186 #endif
187 
188 #if check(delegating_constructors, 0, 200604, 200604, 200604)
189 #error "wrong value for __cpp_delegating_constructors"
190 #endif
191 
192 #if check(nsdmi, 0, 200809, 200809, 200809)
193 #error "wrong value for __cpp_nsdmi"
194 #endif
195 
196 #if check(inheriting_constructors, 0, 201511, 201511, 201511)
197 #error "wrong value for __cpp_inheriting_constructors"
198 #endif
199 
200 #if check(ref_qualifiers, 0, 200710, 200710, 200710)
201 #error "wrong value for __cpp_ref_qualifiers"
202 #endif
203 
204 #if check(alias_templates, 0, 200704, 200704, 200704)
205 #error "wrong value for __cpp_alias_templates"
206 #endif
207 
208 // --- C++98 features ---
209 
210 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
211 #error "wrong value for __cpp_rtti"
212 #endif
213 
214 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
215 #error "wrong value for __cpp_exceptions"
216 #endif
217 
218 // --- TS features --
219 
220 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
221 #error "wrong value for __cpp_experimental_concepts"
222 #endif
223 
224 #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
225 #error "wrong value for __cpp_coroutines"
226 #endif
227