Debian Codegraph @

gcc/testsuite/g++.dg/cpp26/feat-cxx26.C

raw
1 // { dg-options "-std=c++26 -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
2 // { dg-skip-if "requires hosted libstdc++ for complex" { ! hostedlib } }
3
4 // C++98 features:
5
6 #ifndef __cpp_rtti
7 # error "__cpp_rtti"
8 #elif __cpp_rtti != 199711
9 # error "__cpp_rtti != 199711"
10 #endif
11
12 #ifndef __cpp_exceptions
13 # error "__cpp_exceptions"
14 #elif __cpp_exceptions != 199711
15 # error "__cpp_exceptions != 199711"
16 #endif
17
18 // C++11 features:
19
20 #ifndef __cpp_raw_strings
21 # error "__cpp_raw_strings"
22 #elif __cpp_raw_strings != 200710
23 # error "__cpp_raw_strings != 200710"
24 #endif
25
26 #ifndef __cpp_unicode_literals
27 # error "__cpp_unicode_literals"
28 #elif __cpp_unicode_literals != 200710
29 # error "__cpp_unicode_literals != 200710"
30 #endif
31
32 #ifndef __cpp_user_defined_literals
33 # error "__cpp_user_defined_literals"
34 #elif __cpp_user_defined_literals != 200809
35 # error "__cpp_user_defined_literals != 200809"
36 #endif
37
38 #ifndef __cpp_lambdas
39 # error "__cpp_lambdas"
40 #elif __cpp_lambdas != 200907
41 # error "__cpp_lambdas != 200907"
42 #endif
43
44 #ifndef __cpp_range_based_for
45 # error "__cpp_range_based_for"
46 #elif __cpp_range_based_for != 202211
47 # error "__cpp_range_based_for != 202211"
48 #endif
49
50 #ifndef __cpp_decltype
51 # error "__cpp_decltype"
52 #elif __cpp_decltype != 200707
53 # error "__cpp_decltype != 200707"
54 #endif
55
56 #ifndef __cpp_attributes
57 # error "__cpp_attributes"
58 #elif __cpp_attributes != 200809
59 # error "__cpp_attributes != 200809"
60 #endif
61
62 #ifndef __cpp_rvalue_references
63 # error "__cpp_rvalue_references"
64 #elif __cpp_rvalue_references != 200610
65 # error "__cpp_rvalue_references != 200610"
66 #endif
67
68 #ifndef __cpp_variadic_templates
69 # error "__cpp_variadic_templates"
70 #elif __cpp_variadic_templates != 200704
71 # error "__cpp_variadic_templates != 200704"
72 #endif
73
74 #ifndef __cpp_initializer_lists
75 # error "__cpp_initializer_lists"
76 #elif __cpp_initializer_lists != 200806
77 # error "__cpp_initializer_lists != 200806"
78 #endif
79
80 #ifndef __cpp_delegating_constructors
81 # error "__cpp_delegating_constructors"
82 #elif __cpp_delegating_constructors != 200604
83 # error "__cpp_delegating_constructors != 200604"
84 #endif
85
86 #ifndef __cpp_nsdmi
87 # error "__cpp_nsdmi"
88 #elif __cpp_nsdmi != 200809
89 # error "__cpp_nsdmi != 200809"
90 #endif
91
92 #ifndef __cpp_inheriting_constructors
93 # error "__cpp_inheriting_constructors"
94 #elif __cpp_inheriting_constructors!= 201511
95 # error "__cpp_inheriting_constructors != 201511"
96 #endif
97
98 #ifndef __cpp_ref_qualifiers
99 # error "__cpp_ref_qualifiers"
100 #elif __cpp_ref_qualifiers != 200710
101 # error "__cpp_ref_qualifiers != 200710"
102 #endif
103
104 #ifndef __cpp_alias_templates
105 # error "__cpp_alias_templates"
106 #elif __cpp_alias_templates != 200704
107 # error "__cpp_alias_templates != 200704"
108 #endif
109
110 #ifndef __cpp_threadsafe_static_init
111 # error "__cpp_threadsafe_static_init"
112 #elif __cpp_threadsafe_static_init != 200806
113 # error "__cpp_threadsafe_static_init != 200806"
114 #endif
115
116 // C++14 features:
117
118 #ifndef __cpp_binary_literals
119 # error "__cpp_binary_literals"
120 #elif __cpp_binary_literals != 201304
121 # error "__cpp_binary_literals != 201304"
122 #endif
123
124 #ifndef __cpp_init_captures
125 # error "__cpp_init_captures"
126 #elif __cpp_init_captures != 201803
127 # error "__cpp_init_captures != 201803"
128 #endif
129
130 #ifndef __cpp_generic_lambdas
131 # error "__cpp_generic_lambdas"
132 #elif __cpp_generic_lambdas != 201707
133 # error "__cpp_generic_lambdas != 201707"
134 #endif
135
136 #ifndef __cpp_constexpr
137 # error "__cpp_constexpr"
138 #elif __cpp_constexpr != 202406L
139 # error "__cpp_constexpr != 202406L"
140 #endif
141
142 #ifndef __cpp_decltype_auto
143 # error "__cpp_decltype_auto"
144 #elif __cpp_decltype_auto != 201304
145 # error "__cpp_decltype_auto != 201304"
146 #endif
147
148 #ifndef __cpp_return_type_deduction
149 # error "__cpp_return_type_deduction"
150 #elif __cpp_return_type_deduction != 201304
151 # error "__cpp_return_type_deduction != 201304"
152 #endif
153
154 #ifndef __cpp_aggregate_nsdmi
155 # error "__cpp_aggregate_nsdmi"
156 #elif __cpp_aggregate_nsdmi != 201304
157 # error "__cpp_aggregate_nsdmi != 201304"
158 #endif
159
160 #ifndef __cpp_variable_templates
161 # error "__cpp_variable_templates"
162 #elif __cpp_variable_templates != 201304
163 # error "__cpp_variable_templates != 201304"
164 #endif
165
166 #ifndef __cpp_digit_separators
167 # error "__cpp_digit_separators"
168 #elif __cpp_digit_separators != 201309
169 # error "__cpp_digit_separators != 201309"
170 #endif
171
172 #ifndef __cpp_sized_deallocation
173 # error "__cpp_sized_deallocation"
174 #elif __cpp_sized_deallocation != 201309
175 # error "__cpp_sized_deallocation != 201309"
176 #endif
177
178 // GNU VLA support:
179
180 #ifndef __cpp_runtime_arrays
181 # error "__cpp_runtime_arrays"
182 #elif __cpp_runtime_arrays != 198712
183 # error "__cpp_runtime_arrays != 198712"
184 #endif
185
186 // C++11 attributes:
187
188 #ifdef __has_cpp_attribute
189 # if ! __has_cpp_attribute(noreturn)
190 # error "__has_cpp_attribute(noreturn)"
191 # elif __has_cpp_attribute(noreturn) != 200809
192 # error "__has_cpp_attribute(noreturn) != 200809"
193 # endif
194 #else
195 # error "__has_cpp_attribute"
196 #endif
197
198 // Attribute carries_dependency not in yet.
199 //#ifdef __has_cpp_attribute
200 //# if ! __has_cpp_attribute(carries_dependency)
201 //# error "__has_cpp_attribute(carries_dependency)"
202 //# elif __has_cpp_attribute(carries_dependency) != 200809
203 //# error "__has_cpp_attribute(carries_dependency) != 200809"
204 //# endif
205 //#else
206 //# error "__has_cpp_attribute"
207 //#endif
208
209 // C++14 attributes:
210
211 #ifdef __has_cpp_attribute
212 # if ! __has_cpp_attribute(deprecated)
213 # error "__has_cpp_attribute(deprecated)"
214 # elif __has_cpp_attribute(deprecated) != 201309
215 # error "__has_cpp_attribute(deprecated) != 201309"
216 # endif
217 #else
218 # error "__has_cpp_attribute"
219 #endif
220
221 // Include checks:
222
223 // Check for __has_include macro.
224 #ifndef __has_include
225 # error "__has_include"
226 #endif
227
228 // Try known bracket header (use operator).
229 #if __has_include (<complex>)
230 #else
231 # error "<complex>"
232 #endif
233
234 // Define and use a macro to invoke the operator.
235 #define sluggo(TXT) __has_include(TXT)
236
237 #if sluggo(<complex>)
238 #else
239 # error "<complex>"
240 #endif
241
242 #if ! sluggo(<complex>)
243 # error "<complex>"
244 #else
245 #endif
246
247 // Quoted complex.h should find at least the bracket version.
248 #if __has_include("complex.h")
249 #else
250 # error "complex.h"
251 #endif
252
253 // Try known local quote header.
254 #if __has_include("complex_literals.h")
255 #else
256 # error "\"complex_literals.h\""
257 #endif
258
259 // Try nonexistent bracket header.
260 #if __has_include(<stuff>)
261 # error "<stuff>"
262 #else
263 #endif
264
265 // Try nonexistent quote header.
266 #if __has_include("phlegm")
267 # error "\"phlegm\""
268 #else
269 #endif
270
271 // Test __has_include_next.
272 #if __has_include("phoobhar.h")
273 # include "phoobhar.h"
274 #else
275 # error "__has_include(\"phoobhar.h\")"
276 #endif
277
278 // Try a macro.
279 #define COMPLEX_INC "complex.h"
280 #if __has_include(COMPLEX_INC)
281 #else
282 # error COMPLEX_INC
283 #endif
284
285 // Realistic use of __has_include.
286 #if __has_include(<array>)
287 # define STD_ARRAY 1
288 # include <array>
289 template<typename _Tp, std::size_t _Num>
290 using array = std::array<_Tp, _Num>;
291 #elif __has_include(<tr1/array>)
292 # define TR1_ARRAY 1
293 # include <tr1/array>
294 template<typename _Tp, std::size_t _Num>
295 typedef std::tr1::array<_Tp, _Num> array;
296 #endif
297
298 // C++17 features:
299
300 #ifndef __cpp_unicode_characters
301 # error "__cpp_unicode_characters"
302 #elif __cpp_unicode_characters != 201411
303 # error "__cpp_unicode_characters != 201411"
304 #endif
305
306 #ifndef __cpp_static_assert
307 # error "__cpp_static_assert"
308 #elif __cpp_static_assert != 202306
309 # error "__cpp_static_assert != 202306"
310 #endif
311
312 #ifndef __cpp_namespace_attributes
313 # error "__cpp_namespace_attributes"
314 #elif __cpp_namespace_attributes != 201411
315 # error "__cpp_namespace_attributes != 201411"
316 #endif
317
318 #ifndef __cpp_enumerator_attributes
319 # error "__cpp_enumerator_attributes"
320 #elif __cpp_enumerator_attributes != 201411
321 # error "__cpp_enumerator_attributes != 201411"
322 #endif
323
324 #ifndef __cpp_nested_namespace_definitions
325 # error "__cpp_nested_namespace_definitions"
326 #elif __cpp_nested_namespace_definitions != 201411
327 # error "__cpp_nested_namespace_definitions != 201411"
328 #endif
329
330 #ifndef __cpp_fold_expressions
331 # error "__cpp_fold_expressions"
332 #elif __cpp_fold_expressions != 201603
333 # error "__cpp_fold_expressions != 201603"
334 #endif
335
336 #ifndef __cpp_nontype_template_args
337 # error "__cpp_nontype_template_args"
338 #elif __cpp_nontype_template_args != 201911
339 # error "__cpp_nontype_template_args != 201911"
340 #endif
341
342 #ifndef __cpp_hex_float
343 # error "__cpp_hex_float"
344 #elif __cpp_hex_float != 201603
345 # error "__cpp_hex_float != 201603"
346 #endif
347
348 #ifndef __cpp_aggregate_bases
349 # error "__cpp_aggregate_bases"
350 #elif __cpp_aggregate_bases != 201603
351 # error "__cpp_aggregate_bases != 201603"
352 #endif
353
354 #ifndef __cpp_deduction_guides
355 # error "__cpp_deduction_guides"
356 #elif __cpp_deduction_guides != 202207
357 # error "__cpp_deduction_guides != 202207"
358 #endif
359
360 #ifndef __cpp_if_constexpr
361 # error "__cpp_if_constexpr"
362 #elif __cpp_if_constexpr != 201606
363 # error "__cpp_if_constexpr != 201606"
364 #endif
365
366 #ifndef __cpp_aligned_new
367 # error "__cpp_aligned_new"
368 #elif __cpp_aligned_new != 201606
369 # error "__cpp_aligned_new != 201606"
370 #endif
371
372 #ifndef __cpp_template_auto
373 # error "__cpp_template_auto"
374 #elif __cpp_template_auto != 201606
375 # error "__cpp_template_auto != 201606"
376 #endif
377
378 #ifndef __cpp_inline_variables
379 # error "__cpp_inline_variables"
380 #elif __cpp_inline_variables != 201606
381 # error "__cpp_inline_variables != 201606"
382 #endif
383
384 #ifndef __cpp_capture_star_this
385 # error "__cpp_capture_star_this"
386 #elif __cpp_capture_star_this != 201603
387 # error "__cpp_capture_star_this != 201603"
388 #endif
389
390 #ifndef __cpp_noexcept_function_type
391 # error "__cpp_noexcept_function_type"
392 #elif __cpp_noexcept_function_type != 201510
393 # error "__cpp_noexcept_function_type != 201510"
394 #endif
395
396 #ifndef __cpp_structured_bindings
397 # error "__cpp_structured_bindings"
398 #elif __cpp_structured_bindings != 202403
399 # error "__cpp_structured_bindings != 202403"
400 #endif
401
402 #ifndef __cpp_template_template_args
403 # error "__cpp_template_template_args"
404 #elif __cpp_template_template_args != 201611
405 # error "__cpp_template_template_args != 201611"
406 #endif
407
408 #ifndef __cpp_variadic_using
409 # error "__cpp_variadic_using"
410 #elif __cpp_variadic_using != 201611
411 # error "__cpp_variadic_using != 201611"
412 #endif
413
414 #ifndef __cpp_guaranteed_copy_elision
415 # error "__cpp_guaranteed_copy_elision"
416 #elif __cpp_guaranteed_copy_elision != 201606
417 # error "__cpp_guaranteed_copy_elision != 201606"
418 #endif
419
420 #ifndef __cpp_nontype_template_parameter_auto
421 # error "__cpp_nontype_template_parameter_auto"
422 #elif __cpp_nontype_template_parameter_auto != 201606
423 # error "__cpp_nontype_template_parameter_auto != 201606"
424 #endif
425
426 // C++20 features:
427
428 #ifndef __cpp_conditional_explicit
429 # error "__cpp_conditional_explicit"
430 #elif __cpp_conditional_explicit != 201806
431 # error "__cpp_conditional_explicit != 201806"
432 #endif
433
434 #ifndef __cpp_nontype_template_parameter_class
435 # error "__cpp_nontype_template_parameter_class"
436 #elif __cpp_nontype_template_parameter_class != 201806
437 # error "__cpp_nontype_template_parameter_class != 201806"
438 #endif
439
440 #ifndef __cpp_impl_destroying_delete
441 # error "__cpp_impl_destroying_delete"
442 #elif __cpp_impl_destroying_delete != 201806
443 # error "__cpp_impl_destroying_delete != 201806"
444 #endif
445
446 #ifndef __cpp_constinit
447 # error "__cpp_constinit"
448 #elif __cpp_constinit != 201907
449 # error "__cpp_constinit != 201907"
450 #endif
451
452 #ifndef __cpp_constexpr_dynamic_alloc
453 # error "__cpp_constexpr_dynamic_alloc"
454 #elif __cpp_constexpr_dynamic_alloc != 201907
455 # error "__cpp_constexpr_dynamic_alloc != 201907"
456 #endif
457
458 #ifndef __cpp_aggregate_paren_init
459 # error "__cpp_aggregate_paren_init"
460 #elif __cpp_aggregate_paren_init != 201902
461 # error "__cpp_aggregate_paren_init != 201902"
462 #endif
463
464 #ifndef __cpp_char8_t
465 # error "__cpp_char8_t"
466 #elif __cpp_char8_t != 202207
467 # error "__cpp_char8_t != 202207"
468 #endif
469
470 #ifndef __cpp_designated_initializers
471 # error "__cpp_designated_initializers"
472 #elif __cpp_designated_initializers != 201707
473 # error "__cpp_designated_initializers != 201707"
474 #endif
475
476 #ifndef __cpp_constexpr_in_decltype
477 # error "__cpp_constexpr_in_decltype"
478 #elif __cpp_constexpr_in_decltype != 201711
479 # error "__cpp_constexpr_in_decltype != 201711"
480 #endif
481
482 #ifndef __cpp_consteval
483 # error "__cpp_consteval"
484 #elif __cpp_consteval != 202211L
485 # error "__cpp_consteval != 202211L"
486 #endif
487
488 #ifndef __cpp_concepts
489 # error "__cpp_concepts"
490 #elif __cpp_concepts != 202002
491 # error "__cpp_concepts != 202002"
492 #endif
493
494 #ifndef __cpp_using_enum
495 # error "__cpp_using_enum"
496 #elif __cpp_using_enum != 201907
497 # error "__cpp_using_enum != 201907"
498 #endif
499
500 // C++20 attributes:
501
502 #ifdef __has_cpp_attribute
503
504 # if ! __has_cpp_attribute(maybe_unused)
505 # error "__has_cpp_attribute(maybe_unused)"
506 # elif __has_cpp_attribute(maybe_unused) != 201603
507 # error "__has_cpp_attribute(maybe_unused) != 201603"
508 # endif
509
510 # if ! __has_cpp_attribute(nodiscard)
511 # error "__has_cpp_attribute(nodiscard)"
512 # elif __has_cpp_attribute(nodiscard) != 201907
513 # error "__has_cpp_attribute(nodiscard) != 201907"
514 # endif
515
516 # if ! __has_cpp_attribute(fallthrough)
517 # error "__has_cpp_attribute(fallthrough)"
518 # elif __has_cpp_attribute(fallthrough) != 201603
519 # error "__has_cpp_attribute(fallthrough) != 201603"
520 # endif
521
522 # if ! __has_cpp_attribute(no_unique_address)
523 # error "__has_cpp_attribute(no_unique_address)"
524 # elif __has_cpp_attribute(no_unique_address) != 201803
525 # error "__has_cpp_attribute(no_unique_address) != 201803"
526 # endif
527
528 # if ! __has_cpp_attribute(likely)
529 # error "__has_cpp_attribute(likely)"
530 # elif __has_cpp_attribute(likely) != 201803
531 # error "__has_cpp_attribute(likely) != 201803"
532 # endif
533
534 # if ! __has_cpp_attribute(unlikely)
535 # error "__has_cpp_attribute(unlikely)"
536 # elif __has_cpp_attribute(unlikely) != 201803
537 # error "__has_cpp_attribute(unlikely) != 201803"
538 # endif
539
540 #else
541 # error "__has_cpp_attribute"
542 #endif
543
544 // C++23 features:
545
546 #ifndef __cpp_size_t_suffix
547 # error "__cpp_size_t_suffix"
548 #elif __cpp_size_t_suffix != 202011
549 # error "__cpp_size_t_suffix != 202011"
550 #endif
551
552 #ifndef __cpp_if_consteval
553 # error "__cpp_if_consteval"
554 #elif __cpp_if_consteval != 202106
555 # error "__cpp_if_consteval != 202106"
556 #endif
557
558 #ifndef __cpp_multidimensional_subscript
559 # error "__cpp_multidimensional_subscript"
560 #elif __cpp_multidimensional_subscript != 202211
561 # error "__cpp_multidimensional_subscript != 202211"
562 #endif
563
564 #ifndef __cpp_named_character_escapes
565 # error "__cpp_named_character_escapes"
566 #elif __cpp_named_character_escapes != 202207
567 # error "__cpp_named_character_escapes != 202207"
568 #endif
569
570 #ifndef __cpp_static_call_operator
571 # error "__cpp_static_call_operator"
572 #elif __cpp_static_call_operator != 202207
573 # error "__cpp_static_call_operator != 202207"
574 #endif
575
576 #ifndef __cpp_implicit_move
577 # error "__cpp_implicit_move"
578 #elif __cpp_implicit_move != 202207
579 # error "__cpp_implicit_move != 202207"
580 #endif
581
582 #ifndef __cpp_explicit_this_parameter
583 # error "__cpp_explicit_this_parameter"
584 #elif __cpp_explicit_this_parameter != 202110
585 # error "__cpp_explicit_this_parameter != 202110"
586 #endif
587
588 #ifndef __cpp_auto_cast
589 # error "__cpp_auto_cast"
590 #elif __cpp_auto_cast != 202110
591 # error "__cpp_auto_cast != 202110"
592 #endif
593
594 // C++23 attributes:
595
596 #ifdef __has_cpp_attribute
597 # if ! __has_cpp_attribute(assume)
598 # error "__has_cpp_attribute(assume)"
599 # elif __has_cpp_attribute(assume) != 202207
600 # error "__has_cpp_attribute(assume) != 202207"
601 # endif
602 #else
603 # error "__has_cpp_attribute"
604 #endif
605
606 // C++26 features:
607
608 #ifndef __cpp_placeholder_variables
609 # error "__cpp_placeholder_variables"
610 #elif __cpp_placeholder_variables != 202306
611 # error "__cpp_placeholder_variables != 202306"
612 #endif
613
614 #ifndef __cpp_deleted_function
615 # error "__cpp_deleted_function"
616 #elif __cpp_deleted_function != 202403
617 # error "__cpp_deleted_function != 202403"
618 #endif
619
620 #ifndef __cpp_variadic_friend
621 # error "__cpp_variadic_friend"
622 #elif __cpp_variadic_friend != 202403
623 # error "__cpp_variadic_friend != 202403"
624 #endif
625
626 #ifndef __cpp_pack_indexing
627 # error "__cpp_pack_indexing"
628 #elif __cpp_pack_indexing != 202311
629 # error "__cpp_pack_indexing != 202311"
630 #endif
631
632 #ifndef __cpp_pp_embed
633 # error "__cpp_pp_embed"
634 #elif __cpp_pp_embed != 202502
635 # error "__cpp_pp_embed != 202502"
636 #endif