/cp
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / feat-cxx14.C
blob412b9a33b8f46456b0ebec369a2167d645754e44
1 // { dg-options "-std=c++14 -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
3 //  C++98 features:
5 #ifndef __cpp_rtti
6 #  error "__cpp_rtti"
7 #elif  __cpp_rtti != 199711
8 #  error "__cpp_rtti != 199711"
9 #endif
11 #ifndef __cpp_exceptions
12 #  error "__cpp_exceptions"
13 #elif  __cpp_exceptions != 199711
14 #  error "__cpp_exceptions != 199711"
15 #endif
17 //  C++11 features:
19 #ifndef __cpp_unicode_characters
20 #  error "__cpp_unicode_characters"
21 #elif __cpp_unicode_characters != 200704
22 #  error "__cpp_unicode_characters != 200704"
23 #endif
25 #ifndef __cpp_raw_strings
26 #  error "__cpp_raw_strings"
27 #elif __cpp_raw_strings != 200710
28 #  error "__cpp_raw_strings != 200710"
29 #endif
31 #ifndef __cpp_unicode_literals
32 #  error "__cpp_unicode_literals"
33 #elif __cpp_unicode_literals != 200710
34 #  error "__cpp_unicode_literals != 200710"
35 #endif
37 #ifndef __cpp_user_defined_literals
38 #  error "__cpp_user_defined_literals"
39 #elif __cpp_user_defined_literals != 200809
40 #  error "__cpp_user_defined_literals != 200809"
41 #endif
43 #ifndef __cpp_lambdas
44 #  error "__cpp_lambdas"
45 #elif __cpp_lambdas != 200907
46 #  error "__cpp_lambdas != 200907"
47 #endif
49 #ifndef __cpp_range_based_for
50 #  error "__cpp_range_based_for"
51 #elif __cpp_range_based_for < 200907
52 #  error "__cpp_range_based_for < 200907"
53 #endif
55 #ifndef __cpp_static_assert
56 #  error "__cpp_static_assert"
57 #elif __cpp_static_assert != 200410
58 #  error "__cpp_static_assert != 200410"
59 #endif
61 #ifndef __cpp_decltype
62 #  error "__cpp_decltype"
63 #elif __cpp_decltype != 200707
64 #  error "__cpp_decltype != 200707"
65 #endif
67 #ifndef __cpp_attributes
68 #  error "__cpp_attributes"
69 #elif __cpp_attributes != 200809
70 #  error "__cpp_attributes != 200809"
71 #endif
73 #ifndef __cpp_rvalue_references
74 #  error "__cpp_rvalue_references"
75 #elif __cpp_rvalue_references != 200610
76 #  error "__cpp_rvalue_references != 200610"
77 #endif
79 #ifndef __cpp_variadic_templates
80 #  error "__cpp_variadic_templates"
81 #elif __cpp_variadic_templates != 200704
82 #  error "__cpp_variadic_templates != 200704"
83 #endif
85 #ifndef __cpp_initializer_lists
86 #  error "__cpp_initializer_lists"
87 #elif __cpp_initializer_lists != 200806
88 #  error "__cpp_initializer_lists != 200806"
89 #endif
91 #ifndef __cpp_delegating_constructors
92 #  error "__cpp_delegating_constructors"
93 #elif __cpp_delegating_constructors != 200604
94 #  error "__cpp_delegating_constructors != 200604"
95 #endif
97 #ifndef __cpp_nsdmi
98 #  error "__cpp_nsdmi"
99 #elif __cpp_nsdmi != 200809
100 #  error "__cpp_nsdmi != 200809"
101 #endif
103 #ifndef __cpp_inheriting_constructors
104 #  error "__cpp_inheriting_constructors"
105 #elif  __cpp_inheriting_constructors!= 201511
106 #  error "__cpp_inheriting_constructors != 201511"
107 #endif
109 #ifndef __cpp_ref_qualifiers
110 #  error "__cpp_ref_qualifiers"
111 #elif __cpp_ref_qualifiers != 200710
112 #  error "__cpp_ref_qualifiers != 200710"
113 #endif
115 #ifndef __cpp_alias_templates
116 #  error "__cpp_alias_templates"
117 #elif __cpp_alias_templates != 200704
118 #  error "__cpp_alias_templates != 200704"
119 #endif
121 #ifndef __cpp_threadsafe_static_init
122 #  error "__cpp_threadsafe_static_init"
123 #elif __cpp_threadsafe_static_init != 200806
124 #  error "__cpp_threadsafe_static_init != 200806"
125 #endif
127 //  C++14 features:
129 #ifndef __cpp_binary_literals
130 #  error "__cpp_binary_literals"
131 #elif __cpp_binary_literals != 201304
132 #  error "__cpp_binary_literals != 201304"
133 #endif
135 #ifndef __cpp_init_captures
136 #  error "__cpp_init_captures"
137 #elif __cpp_init_captures != 201304
138 #  error "__cpp_init_captures != 201304"
139 #endif
141 #ifndef __cpp_generic_lambdas
142 #  error "__cpp_generic_lambdas"
143 #elif __cpp_generic_lambdas != 201304
144 #  error "__cpp_generic_lambdas != 201304"
145 #endif
147 #ifndef __cpp_constexpr
148 #  error "__cpp_constexpr"
149 #elif __cpp_constexpr != 201304
150 #  error "__cpp_constexpr != 201304"
151 #endif
153 #ifndef __cpp_decltype_auto
154 #  error "__cpp_decltype_auto"
155 #elif __cpp_decltype_auto != 201304
156 #  error "__cpp_decltype_auto != 201304"
157 #endif
159 #ifndef __cpp_return_type_deduction
160 #  error "__cpp_return_type_deduction"
161 #elif __cpp_return_type_deduction != 201304
162 #  error "__cpp_return_type_deduction != 201304"
163 #endif
165 #ifndef __cpp_aggregate_nsdmi
166 #  error "__cpp_aggregate_nsdmi"
167 #elif __cpp_aggregate_nsdmi != 201304
168 #  error "__cpp_aggregate_nsdmi != 201304"
169 #endif
171 #ifndef __cpp_variable_templates
172 #  error "__cpp_variable_templates"
173 #elif __cpp_variable_templates != 201304
174 #  error "__cpp_variable_templates != 201304"
175 #endif
177 #ifndef __cpp_digit_separators
178 #  error "__cpp_digit_separators"
179 #elif __cpp_digit_separators != 201309
180 #  error "__cpp_digit_separators != 201309"
181 #endif
183 #ifndef __cpp_sized_deallocation
184 #  error "__cpp_sized_deallocation"
185 #elif __cpp_sized_deallocation != 201309
186 #  error "__cpp_sized_deallocation != 201309"
187 #endif
189 //  GNU VLA support:
191 #ifndef __cpp_runtime_arrays
192 #  error "__cpp_runtime_arrays"
193 #elif __cpp_runtime_arrays != 198712
194 #  error "__cpp_runtime_arrays != 198712"
195 #endif
197 //  C++11 attributes:
199 #ifdef __has_cpp_attribute
200 #  if ! __has_cpp_attribute(noreturn)
201 #    error "__has_cpp_attribute(noreturn)"
202 #  elif __has_cpp_attribute(noreturn) != 200809
203 #    error "__has_cpp_attribute(noreturn) != 200809"
204 #  endif
205 #else
206 #  error "__has_cpp_attribute"
207 #endif
209 //  Attribute carries_dependency not in yet.
210 //#ifdef __has_cpp_attribute
211 //#  if ! __has_cpp_attribute(carries_dependency)
212 //#    error "__has_cpp_attribute(carries_dependency)"
213 //#  elif __has_cpp_attribute(carries_dependency) != 200809
214 //#    error "__has_cpp_attribute(carries_dependency) != 200809"
215 //#  endif
216 //#else
217 //#  error "__has_cpp_attribute"
218 //#endif
220 //  C++14 attributes:
222 #ifdef __has_cpp_attribute
223 #  if ! __has_cpp_attribute(deprecated)
224 #    error "__has_cpp_attribute(deprecated)"
225 #  elif __has_cpp_attribute(deprecated) != 201309
226 #    error "__has_cpp_attribute(deprecated) != 201309"
227 #  endif
228 #else
229 #  error "__has_cpp_attribute"
230 #endif
232 //  Include checks:
234 //  Check for __has_include macro.
235 #ifndef __has_include
236 #  error "__has_include"
237 #endif
239 //  Quoted complex.h should find at least the bracket version (use operator).
240 #if __has_include__ "complex.h"
241 #else
242 #  error "complex.h"
243 #endif
245 //  Try known bracket header (use operator).
246 #if __has_include__(<complex>)
247 #else
248 #  error "<complex>"
249 #endif
251 //  Define and use a macro to invoke the operator.
252 #define sluggo(TXT) __has_include__(TXT)
254 #if sluggo(<complex>)
255 #else
256 #  error "<complex>"
257 #endif
259 #if ! sluggo(<complex>)
260 #  error "<complex>"
261 #else
262 #endif
264 //  Quoted complex.h should find at least the bracket version.
265 #if __has_include("complex.h")
266 #else
267 #  error "complex.h"
268 #endif
270 //  Try known local quote header.
271 #if __has_include("complex_literals.h")
272 #else
273 #  error "\"complex_literals.h\""
274 #endif
276 //  Try nonexistent bracket header.
277 #if __has_include(<stuff>)
278 #  error "<stuff>"
279 #else
280 #endif
282 //  Try nonexistent quote header.
283 #if __has_include("phlegm")
284 #  error "\"phlegm\""
285 #else
286 #endif
288 //  Test __has_include_next.
289 #if __has_include("phoobhar.h")
290 #  include "phoobhar.h"
291 #else
292 #  error "__has_include(\"phoobhar.h\")"
293 #endif
295 //  Try a macro.
296 #define COMPLEX_INC "complex.h"
297 #if __has_include(COMPLEX_INC)
298 #else
299 #  error COMPLEX_INC
300 #endif
302 //  Realistic use of __has_include.
303 #if __has_include(<array>)
304 #  define STD_ARRAY 1
305 #  include <array>
306   template<typename _Tp, size_t _Num>
307     using array = std::array<_Tp, _Num>;
308 #elif __has_include(<tr1/array>)
309 #  define TR1_ARRAY 1
310 #  include <tr1/array>
311   template<typename _Tp, size_t _Num>
312     typedef std::tr1::array<_Tp, _Num> array;
313 #endif