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