Remove N3639 "array of runtime length" from -std=c++14.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / feat-cxx14.C
blobd271752ec10c06ae43e39be99bb0697aa0a33097
1 // { dg-do compile { target c++14 } }
2 // { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
4 //  C++98 features:
6 #ifndef __cpp_rtti
7 #  error "__cpp_rtti"
8 #elif  __cpp_rtti != 199711
9 #  error "__cpp_rtti != 199711"
10 #endif
12 #ifndef __cpp_exceptions
13 #  error "__cpp_exceptions"
14 #elif  __cpp_exceptions != 199711
15 #  error "__cpp_exceptions != 199711"
16 #endif
18 //  C++11 features:
20 #ifndef __cpp_unicode_characters
21 #  error "__cpp_unicode_characters"
22 #elif __cpp_unicode_characters != 200704
23 #  error "__cpp_unicode_characters != 200704"
24 #endif
26 #ifndef __cpp_raw_strings
27 #  error "__cpp_raw_strings"
28 #elif __cpp_raw_strings != 200710
29 #  error "__cpp_raw_strings != 200710"
30 #endif
32 #ifndef __cpp_unicode_literals
33 #  error "__cpp_unicode_literals"
34 #elif __cpp_unicode_literals != 200710
35 #  error "__cpp_unicode_literals != 200710"
36 #endif
38 #ifndef __cpp_user_defined_literals
39 #  error "__cpp_user_defined_literals"
40 #elif __cpp_user_defined_literals != 200809
41 #  error "__cpp_user_defined_literals != 200809"
42 #endif
44 #ifndef __cpp_lambdas
45 #  error "__cpp_lambdas"
46 #elif __cpp_lambdas != 200907
47 #  error "__cpp_lambdas != 200907"
48 #endif
50 #ifndef __cpp_constexpr
51 #  error "__cpp_constexpr"
52 #elif __cpp_constexpr != 200704
53 #  error "__cpp_constexpr != 200704"
54 #endif
56 #ifndef __cpp_range_based_for
57 #  error "__cpp_range_based_for"
58 #elif __cpp_range_based_for != 200907
59 #  error "__cpp_range_based_for != 200907"
60 #endif
62 #ifndef __cpp_static_assert
63 #  error "__cpp_static_assert"
64 #elif __cpp_static_assert != 200410
65 #  error "__cpp_static_assert != 200410"
66 #endif
68 #ifndef __cpp_decltype
69 #  error "__cpp_decltype"
70 #elif __cpp_decltype != 200707
71 #  error "__cpp_decltype != 200707"
72 #endif
74 #ifndef __cpp_attributes
75 #  error "__cpp_attributes"
76 #elif __cpp_attributes != 200809
77 #  error "__cpp_attributes != 200809"
78 #endif
80 #ifndef __cpp_rvalue_reference
81 #  error "__cpp_rvalue_reference"
82 #elif __cpp_rvalue_reference != 200610
83 #  error "__cpp_rvalue_reference != 200610"
84 #endif
86 #ifndef __cpp_variadic_templates
87 #  error "__cpp_variadic_templates"
88 #elif __cpp_variadic_templates != 200704
89 #  error "__cpp_variadic_templates != 200704"
90 #endif
92 #ifndef __cpp_initializer_lists
93 #  error "__cpp_initializer_lists"
94 #elif __cpp_initializer_lists != 200806
95 #  error "__cpp_initializer_lists != 200806"
96 #endif
98 #ifndef __cpp_delegating_constructors
99 #  error "__cpp_delegating_constructors"
100 #elif __cpp_delegating_constructors != 200604
101 #  error "__cpp_delegating_constructors != 200604"
102 #endif
104 #ifndef __cpp_nsdmi
105 #  error "__cpp_nsdmi"
106 #elif __cpp_nsdmi != 200809
107 #  error "__cpp_nsdmi != 200809"
108 #endif
110 #ifndef __cpp_inheriting_constructors
111 #  error "__cpp_inheriting_constructors"
112 #elif  __cpp_inheriting_constructors!= 200802
113 #  error "__cpp_inheriting_constructors != 200802"
114 #endif
116 #ifndef __cpp_ref_qualifiers
117 #  error "__cpp_ref_qualifiers"
118 #elif __cpp_ref_qualifiers != 200710
119 #  error "__cpp_ref_qualifiers != 200710"
120 #endif
122 #ifndef __cpp_alias_templates
123 #  error "__cpp_alias_templates"
124 #elif __cpp_alias_templates != 200704
125 #  error "__cpp_alias_templates != 200704"
126 #endif
128 //  C++14 features:
130 #ifndef __cpp_binary_literals
131 #  error "__cpp_binary_literals"
132 #elif __cpp_binary_literals != 201304
133 #  error "__cpp_binary_literals != 201304"
134 #endif
136 #ifndef __cpp_init_captures
137 #  error "__cpp_init_captures"
138 #elif __cpp_init_captures != 201304
139 #  error "__cpp_init_captures != 201304"
140 #endif
142 #ifndef __cpp_generic_lambdas
143 #  error "__cpp_generic_lambdas"
144 #elif __cpp_generic_lambdas != 201304
145 #  error "__cpp_generic_lambdas != 201304"
146 #endif
148 //  TODO: Change 200704 to 201304 when C++14 constexpr goes in.
149 #ifndef __cpp_constexpr
150 #  error "__cpp_constexpr"
151 #elif __cpp_constexpr != 200704
152 #  error "__cpp_constexpr != 200704"
153 #endif
155 #ifndef __cpp_decltype_auto
156 #  error "__cpp_decltype_auto"
157 #elif __cpp_decltype_auto != 201304
158 #  error "__cpp_decltype_auto != 201304"
159 #endif
161 #ifndef __cpp_return_type_deduction
162 #  error "__cpp_return_type_deduction"
163 #elif __cpp_return_type_deduction != 201304
164 #  error "__cpp_return_type_deduction != 201304"
165 #endif
167 #ifndef __cpp_aggregate_nsdmi
168 #  error "__cpp_aggregate_nsdmi"
169 #elif __cpp_aggregate_nsdmi != 201304
170 #  error "__cpp_aggregate_nsdmi != 201304"
171 #endif
173 #ifndef __cpp_variable_templates
174 #  error "__cpp_variable_templates"
175 #elif __cpp_variable_templates != 201304
176 #  error "__cpp_variable_templates != 201304"
177 #endif
179 #ifndef __cpp_digit_separators
180 #  error "__cpp_digit_separators"
181 #elif __cpp_digit_separators != 201309
182 #  error "__cpp_digit_separators != 201309"
183 #endif
185 //  Sized deallocation not in yet.
186 #ifdef __cpp_sized_deallocation
187 #  error "__cpp_sized_deallocation"
188 #endif
190 //  GNU VLA support:
192 #ifndef __cpp_runtime_arrays
193 #  error "__cpp_runtime_arrays"
194 #elif __cpp_runtime_arrays != 198712
195 #  error "__cpp_runtime_arrays != 198712"
196 #endif
198 //  C++11 attributes:
200 #ifdef __has_cpp_attribute
201 #  if ! __has_cpp_attribute(noreturn)
202 #    error "__has_cpp_attribute(noreturn)"
203 #  elif __has_cpp_attribute(noreturn) != 200809
204 #    error "__has_cpp_attribute(noreturn) != 200809"
205 #  endif
206 #else
207 #  error "__has_cpp_attribute"
208 #endif
210 //  Attribute carries_dependency not in yet.
211 //#ifdef __has_cpp_attribute
212 //#  if ! __has_cpp_attribute(carries_dependency)
213 //#    error "__has_cpp_attribute(carries_dependency)"
214 //#  elif __has_cpp_attribute(carries_dependency) != 200809
215 //#    error "__has_cpp_attribute(carries_dependency) != 200809"
216 //#  endif
217 //#else
218 //#  error "__has_cpp_attribute"
219 //#endif
221 //  C++14 attributes:
223 #ifdef __has_cpp_attribute
224 #  if ! __has_cpp_attribute(deprecated)
225 #    error "__has_cpp_attribute(deprecated)"
226 #  elif __has_cpp_attribute(deprecated) != 201309
227 #    error "__has_cpp_attribute(deprecated) != 201309"
228 #  endif
229 #else
230 #  error "__has_cpp_attribute"
231 #endif
233 //  Include checks:
235 //  Check for __has_include macro.
236 #ifndef __has_include
237 #  error "__has_include"
238 #endif
240 //  Quoted complex.h should find at least the bracket version (use operator).
241 #if __has_include__ "complex.h"
242 #else
243 #  error "complex.h"
244 #endif
246 //  Try known bracket header (use operator).
247 #if __has_include__(<complex>)
248 #else
249 #  error "<complex>"
250 #endif
252 //  Define and use a macro to invoke the operator.
253 #define sluggo(TXT) __has_include__(TXT)
255 #if sluggo(<complex>)
256 #else
257 #  error "<complex>"
258 #endif
260 #if ! sluggo(<complex>)
261 #  error "<complex>"
262 #else
263 #endif
265 //  Quoted complex.h should find at least the bracket version.
266 #if __has_include("complex.h")
267 #else
268 #  error "complex.h"
269 #endif
271 //  Try known local quote header.
272 #if __has_include("complex_literals.h")
273 #else
274 #  error "\"complex_literals.h\""
275 #endif
277 //  Try nonexistent bracket header.
278 #if __has_include(<stuff>)
279 #  error "<stuff>"
280 #else
281 #endif
283 //  Try nonexistent quote header.
284 #if __has_include("phlegm")
285 #  error "\"phlegm\""
286 #else
287 #endif
289 //  Test __has_include_next.
290 #if __has_include("phoobhar.h")
291 #  include "phoobhar.h"
292 #else
293 #  error "__has_include(\"phoobhar.h\")"
294 #endif
296 //  Try a macro.
297 #define COMPLEX_INC "complex.h"
298 #if __has_include(COMPLEX_INC)
299 #else
300 #  error COMPLEX_INC
301 #endif
303 //  Realistic use of __has_include.
304 #if __has_include(<array>)
305 #  define STD_ARRAY 1
306 #  include <array>
307   template<typename _Tp, size_t _Num>
308     using array = std::array<_Tp, _Num>;
309 #elif __has_include(<tr1/array>)
310 #  define TR1_ARRAY 1
311 #  include <tr1/array>
312   template<typename _Tp, size_t _Num>
313     typedef std::tr1::array<_Tp, _Num> array;
314 #endif