Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C

raw
1 // { dg-do compile }
2 // { dg-options "-std=c++17 -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
3 // { dg-skip-if "requires hosted libstdc++ for complex" { ! hostedlib } }
4
5 // C++98 features:
6
7 #ifndef __cpp_rtti
8 # error "__cpp_rtti"
9 #elif __cpp_rtti != 199711
10 # error "__cpp_rtti != 199711"
11 #endif
12
13 #ifndef __cpp_exceptions
14 # error "__cpp_exceptions"
15 #elif __cpp_exceptions != 199711
16 # error "__cpp_exceptions != 199711"
17 #endif
18
19 // C++11 features:
20
21 #ifndef __cpp_raw_strings
22 # error "__cpp_raw_strings"
23 #elif __cpp_raw_strings != 200710
24 # error "__cpp_raw_strings != 200710"
25 #endif
26
27 #ifndef __cpp_unicode_literals
28 # error "__cpp_unicode_literals"
29 #elif __cpp_unicode_literals != 200710
30 # error "__cpp_unicode_literals != 200710"
31 #endif
32
33 #ifndef __cpp_user_defined_literals
34 # error "__cpp_user_defined_literals"
35 #elif __cpp_user_defined_literals != 200809
36 # error "__cpp_user_defined_literals != 200809"
37 #endif
38
39 #ifndef __cpp_lambdas
40 # error "__cpp_lambdas"
41 #elif __cpp_lambdas != 200907
42 # error "__cpp_lambdas != 200907"
43 #endif
44
45 #ifndef __cpp_range_based_for
46 # error "__cpp_range_based_for"
47 #elif __cpp_range_based_for != 201603
48 # error "__cpp_range_based_for != 201603"
49 #endif
50
51 #ifndef __cpp_decltype
52 # error "__cpp_decltype"
53 #elif __cpp_decltype != 200707
54 # error "__cpp_decltype != 200707"
55 #endif
56
57 #ifndef __cpp_attributes
58 # error "__cpp_attributes"
59 #elif __cpp_attributes != 200809
60 # error "__cpp_attributes != 200809"
61 #endif
62
63 #ifndef __cpp_rvalue_references
64 # error "__cpp_rvalue_references"
65 #elif __cpp_rvalue_references != 200610
66 # error "__cpp_rvalue_references != 200610"
67 #endif
68
69 #ifndef __cpp_variadic_templates
70 # error "__cpp_variadic_templates"
71 #elif __cpp_variadic_templates != 200704
72 # error "__cpp_variadic_templates != 200704"
73 #endif
74
75 #ifndef __cpp_initializer_lists
76 # error "__cpp_initializer_lists"
77 #elif __cpp_initializer_lists != 200806
78 # error "__cpp_initializer_lists != 200806"
79 #endif
80
81 #ifndef __cpp_delegating_constructors
82 # error "__cpp_delegating_constructors"
83 #elif __cpp_delegating_constructors != 200604
84 # error "__cpp_delegating_constructors != 200604"
85 #endif
86
87 #ifndef __cpp_nsdmi
88 # error "__cpp_nsdmi"
89 #elif __cpp_nsdmi != 200809
90 # error "__cpp_nsdmi != 200809"
91 #endif
92
93 #ifndef __cpp_inheriting_constructors
94 # error "__cpp_inheriting_constructors"
95 #elif __cpp_inheriting_constructors!= 201511
96 # error "__cpp_inheriting_constructors != 201511"
97 #endif
98
99 #ifndef __cpp_ref_qualifiers
100 # error "__cpp_ref_qualifiers"
101 #elif __cpp_ref_qualifiers != 200710
102 # error "__cpp_ref_qualifiers != 200710"
103 #endif
104
105 #ifndef __cpp_alias_templates
106 # error "__cpp_alias_templates"
107 #elif __cpp_alias_templates != 200704
108 # error "__cpp_alias_templates != 200704"
109 #endif
110
111 #ifndef __cpp_threadsafe_static_init
112 # error "__cpp_threadsafe_static_init"
113 #elif __cpp_threadsafe_static_init != 200806
114 # error "__cpp_threadsafe_static_init != 200806"
115 #endif
116
117 // C++14 features:
118
119 #ifndef __cpp_binary_literals
120 # error "__cpp_binary_literals"
121 #elif __cpp_binary_literals != 201304
122 # error "__cpp_binary_literals != 201304"
123 #endif
124
125 #ifndef __cpp_init_captures
126 # error "__cpp_init_captures"
127 #elif __cpp_init_captures != 201304
128 # error "__cpp_init_captures != 201304"
129 #endif
130
131 #ifndef __cpp_generic_lambdas
132 # error "__cpp_generic_lambdas"
133 #elif __cpp_generic_lambdas != 201304
134 # error "__cpp_generic_lambdas != 201304"
135 #endif
136
137 #ifndef __cpp_constexpr
138 # error "__cpp_constexpr"
139 #elif __cpp_constexpr != 201603
140 # error "__cpp_constexpr != 201603"
141 #endif
142
143 #ifndef __cpp_decltype_auto
144 # error "__cpp_decltype_auto"
145 #elif __cpp_decltype_auto != 201304
146 # error "__cpp_decltype_auto != 201304"
147 #endif
148
149 #ifndef __cpp_return_type_deduction
150 # error "__cpp_return_type_deduction"
151 #elif __cpp_return_type_deduction != 201304
152 # error "__cpp_return_type_deduction != 201304"
153 #endif
154
155 #ifndef __cpp_aggregate_nsdmi
156 # error "__cpp_aggregate_nsdmi"
157 #elif __cpp_aggregate_nsdmi != 201304
158 # error "__cpp_aggregate_nsdmi != 201304"
159 #endif
160
161 #ifndef __cpp_variable_templates
162 # error "__cpp_variable_templates"
163 #elif __cpp_variable_templates != 201304
164 # error "__cpp_variable_templates != 201304"
165 #endif
166
167 #ifndef __cpp_digit_separators
168 # error "__cpp_digit_separators"
169 #elif __cpp_digit_separators != 201309
170 # error "__cpp_digit_separators != 201309"
171 #endif
172
173 #ifndef __cpp_sized_deallocation
174 # error "__cpp_sized_deallocation"
175 #elif __cpp_sized_deallocation != 201309
176 # error "__cpp_sized_deallocation != 201309"
177 #endif
178
179 // GNU VLA support:
180
181 #ifndef __cpp_runtime_arrays
182 # error "__cpp_runtime_arrays"
183 #elif __cpp_runtime_arrays != 198712
184 # error "__cpp_runtime_arrays != 198712"
185 #endif
186
187 // C++11 attributes:
188
189 #ifdef __has_cpp_attribute
190 # if ! __has_cpp_attribute(noreturn)
191 # error "__has_cpp_attribute(noreturn)"
192 # elif __has_cpp_attribute(noreturn) != 200809
193 # error "__has_cpp_attribute(noreturn) != 200809"
194 # endif
195 #else
196 # error "__has_cpp_attribute"
197 #endif
198
199 // Attribute carries_dependency not in yet.
200 //#ifdef __has_cpp_attribute
201 //# if ! __has_cpp_attribute(carries_dependency)
202 //# error "__has_cpp_attribute(carries_dependency)"
203 //# elif __has_cpp_attribute(carries_dependency) != 200809
204 //# error "__has_cpp_attribute(carries_dependency) != 200809"
205 //# endif
206 //#else
207 //# error "__has_cpp_attribute"
208 //#endif
209
210 // C++14 attributes:
211
212 #ifdef __has_cpp_attribute
213 # if ! __has_cpp_attribute(deprecated)
214 # error "__has_cpp_attribute(deprecated)"
215 # elif __has_cpp_attribute(deprecated) != 201309
216 # error "__has_cpp_attribute(deprecated) != 201309"
217 # endif
218 #else
219 # error "__has_cpp_attribute"
220 #endif
221
222 // Include checks:
223
224 // Check for __has_include macro.
225 #ifndef __has_include
226 # error "__has_include"
227 #endif
228
229 // Try known bracket header (use operator).
230 #if __has_include (<complex>)
231 #else
232 # error "<complex>"
233 #endif
234
235 // Define and use a macro to invoke the operator.
236 #define sluggo(TXT) __has_include(TXT)
237
238 #if sluggo(<complex>)
239 #else
240 # error "<complex>"
241 #endif
242
243 #if ! sluggo(<complex>)
244 # error "<complex>"
245 #else
246 #endif
247
248 // Quoted complex.h should find at least the bracket version.
249 #if __has_include("complex.h")
250 #else
251 # error "complex.h"
252 #endif
253
254 // Try known local quote header.
255 #if __has_include("complex_literals.h")
256 #else
257 # error "\"complex_literals.h\""
258 #endif
259
260 // Try nonexistent bracket header.
261 #if __has_include(<stuff>)
262 # error "<stuff>"
263 #else
264 #endif
265
266 // Try nonexistent quote header.
267 #if __has_include("phlegm")
268 # error "\"phlegm\""
269 #else
270 #endif
271
272 // Test __has_include_next.
273 #if __has_include("phoobhar.h")
274 # include "phoobhar.h"
275 #else
276 # error "__has_include(\"phoobhar.h\")"
277 #endif
278
279 // Try a macro.
280 #define COMPLEX_INC "complex.h"
281 #if __has_include(COMPLEX_INC)
282 #else
283 # error COMPLEX_INC
284 #endif
285
286 // Realistic use of __has_include.
287 #if __has_include(<array>)
288 # define STD_ARRAY 1
289 # include <array>
290 template<typename _Tp, std::size_t _Num>
291 using array = std::array<_Tp, _Num>;
292 #elif __has_include(<tr1/array>)
293 # define TR1_ARRAY 1
294 # include <tr1/array>
295 template<typename _Tp, std::size_t _Num>
296 typedef std::tr1::array<_Tp, _Num> array;
297 #endif
298
299 // C++17 features:
300
301 #ifndef __cpp_unicode_characters
302 # error "__cpp_unicode_characters"
303 #elif __cpp_unicode_characters != 201411
304 # error "__cpp_unicode_characters != 201411"
305 #endif
306
307 #ifndef __cpp_static_assert
308 # error "__cpp_static_assert"
309 #elif __cpp_static_assert != 201411
310 # error "__cpp_static_assert != 201411"
311 #endif
312
313 #ifndef __cpp_namespace_attributes
314 # error "__cpp_namespace_attributes"
315 #elif __cpp_namespace_attributes != 201411
316 # error "__cpp_namespace_attributes != 201411"
317 #endif
318
319 #ifndef __cpp_enumerator_attributes
320 # error "__cpp_enumerator_attributes"
321 #elif __cpp_enumerator_attributes != 201411
322 # error "__cpp_enumerator_attributes != 201411"
323 #endif
324
325 #ifndef __cpp_nested_namespace_definitions
326 # error "__cpp_nested_namespace_definitions"
327 #elif __cpp_nested_namespace_definitions != 201411
328 # error "__cpp_nested_namespace_definitions != 201411"
329 #endif
330
331 #ifndef __cpp_fold_expressions
332 # error "__cpp_fold_expressions"
333 #elif __cpp_fold_expressions != 201603
334 # error "__cpp_fold_expressions != 201603"
335 #endif
336
337 #ifndef __cpp_nontype_template_args
338 # error "__cpp_nontype_template_args"
339 #elif __cpp_nontype_template_args != 201411
340 # error "__cpp_nontype_template_args != 201411"
341 #endif
342
343 #ifndef __cpp_hex_float
344 # error "__cpp_hex_float"
345 #elif __cpp_hex_float != 201603
346 # error "__cpp_hex_float != 201603"
347 #endif
348
349 #ifndef __cpp_aggregate_bases
350 # error "__cpp_aggregate_bases"
351 #elif __cpp_aggregate_bases != 201603
352 # error "__cpp_aggregate_bases != 201603"
353 #endif
354
355 #ifndef __cpp_deduction_guides
356 # error "__cpp_deduction_guides"
357 #elif __cpp_deduction_guides != 201703
358 # error "__cpp_deduction_guides != 201703"
359 #endif
360
361 #ifndef __cpp_if_constexpr
362 # error "__cpp_if_constexpr"
363 #elif __cpp_if_constexpr != 201606
364 # error "__cpp_if_constexpr != 201606"
365 #endif
366
367 #ifndef __cpp_aligned_new
368 # error "__cpp_aligned_new"
369 #elif __cpp_aligned_new != 201606
370 # error "__cpp_aligned_new != 201606"
371 #endif
372
373 #ifndef __cpp_template_auto
374 # error "__cpp_template_auto"
375 #elif __cpp_template_auto != 201606
376 # error "__cpp_template_auto != 201606"
377 #endif
378
379 #ifndef __cpp_inline_variables
380 # error "__cpp_inline_variables"
381 #elif __cpp_inline_variables != 201606
382 # error "__cpp_inline_variables != 201606"
383 #endif
384
385 #ifndef __cpp_capture_star_this
386 # error "__cpp_capture_star_this"
387 #elif __cpp_capture_star_this != 201603
388 # error "__cpp_capture_star_this != 201603"
389 #endif
390
391 #ifndef __cpp_noexcept_function_type
392 # error "__cpp_noexcept_function_type"
393 #elif __cpp_noexcept_function_type != 201510
394 # error "__cpp_noexcept_function_type != 201510"
395 #endif
396
397 #ifndef __cpp_structured_bindings
398 # error "__cpp_structured_bindings"
399 #elif __cpp_structured_bindings != 201606
400 # error "__cpp_structured_bindings != 201606"
401 #endif
402
403 #ifndef __cpp_template_template_args
404 # error "__cpp_template_template_args"
405 #elif __cpp_template_template_args != 201611
406 # error "__cpp_template_template_args != 201611"
407 #endif
408
409 #ifndef __cpp_variadic_using
410 # error "__cpp_variadic_using"
411 #elif __cpp_variadic_using != 201611
412 # error "__cpp_variadic_using != 201611"
413 #endif
414
415 #ifndef __cpp_guaranteed_copy_elision
416 # error "__cpp_guaranteed_copy_elision"
417 #elif __cpp_guaranteed_copy_elision != 201606
418 # error "__cpp_guaranteed_copy_elision != 201606"
419 #endif
420
421 #ifndef __cpp_nontype_template_parameter_auto
422 # error "__cpp_nontype_template_parameter_auto"
423 #elif __cpp_nontype_template_parameter_auto != 201606
424 # error "__cpp_nontype_template_parameter_auto != 201606"
425 #endif
426
427 #ifdef __has_cpp_attribute
428
429 # if ! __has_cpp_attribute(maybe_unused)
430 # error "__has_cpp_attribute(maybe_unused)"
431 # elif __has_cpp_attribute(maybe_unused) != 201603
432 # error "__has_cpp_attribute(maybe_unused) != 201603"
433 # endif
434
435 # if ! __has_cpp_attribute(nodiscard)
436 # error "__has_cpp_attribute(nodiscard)"
437 # elif (__has_cpp_attribute(nodiscard) != 201603 && __has_cpp_attribute(nodiscard) != 201907)
438 # error "__has_cpp_attribute(nodiscard) != 201603"
439 # endif
440
441 # if ! __has_cpp_attribute(fallthrough)
442 # error "__has_cpp_attribute(fallthrough)"
443 # elif __has_cpp_attribute(fallthrough) != 201603
444 # error "__has_cpp_attribute(fallthrough) != 201603"
445 # endif
446
447 #else
448 # error "__has_cpp_attribute"
449 #endif