2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / feat-cxx14.C
blob18ff09884650fbb0d78d7b6ea07b5ab5c627670d
1 // { dg-do compile { target c++14 } }
2 // { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
4 // Begin C++11 tests.
6 #ifndef __cpp_unicode_characters
7 #  error "__cpp_unicode_characters"
8 #elif __cpp_unicode_characters != 200704
9 #  error "__cpp_unicode_characters != 200704"
10 #endif
12 #ifndef __cpp_raw_strings
13 #  error "__cpp_raw_strings"
14 #elif __cpp_raw_strings != 200710
15 #  error "__cpp_raw_strings != 200710"
16 #endif
18 #ifndef __cpp_unicode_literals
19 #  error "__cpp_unicode_literals"
20 #elif __cpp_unicode_literals != 200710
21 #  error "__cpp_unicode_literals != 200710"
22 #endif
24 #ifndef __cpp_user_defined_literals
25 #  error "__cpp_user_defined_literals"
26 #elif __cpp_user_defined_literals != 200809
27 #  error "__cpp_user_defined_literals != 200809"
28 #endif
30 #ifndef __cpp_lambdas
31 #  error "__cpp_lambdas"
32 #elif __cpp_lambdas != 200907
33 #  error "__cpp_lambdas != 200907"
34 #endif
36 #ifndef __cpp_constexpr
37 #  error "__cpp_constexpr"
38 #elif __cpp_constexpr != 200704
39 #  error "__cpp_constexpr != 200704"
40 #endif
42 #ifndef __cpp_static_assert
43 #  error "__cpp_static_assert"
44 #elif __cpp_static_assert != 200410
45 #  error "__cpp_static_assert != 200410"
46 #endif
48 #ifndef __cpp_decltype
49 #  error "__cpp_decltype"
50 #elif __cpp_decltype != 200707
51 #  error "__cpp_decltype != 200707"
52 #endif
54 #ifndef __cpp_attributes
55 #  error "__cpp_attributes"
56 #elif __cpp_attributes != 200809
57 #  error "__cpp_attributes != 200809"
58 #endif
60 #ifndef __cpp_rvalue_reference
61 #  error "__cpp_rvalue_reference"
62 #elif __cpp_rvalue_reference != 200610
63 #  error "__cpp_rvalue_reference != 200610"
64 #endif
66 #ifndef __cpp_variadic_templates
67 #  error "__cpp_variadic_templates"
68 #elif __cpp_variadic_templates != 200704
69 #  error "__cpp_variadic_templates != 200704"
70 #endif
72 #ifndef __cpp_alias_templates
73 #  error "__cpp_alias_templates"
74 #elif __cpp_alias_templates != 200704
75 #  error "__cpp_alias_templates != 200704"
76 #endif
78 // Begin C++14 tests.
80 #ifndef __cpp_binary_literals
81 #  error "__cpp_binary_literals"
82 #elif __cpp_binary_literals != 201304
83 #  error "__cpp_binary_literals != 201304"
84 #endif
86 #ifndef __cpp_init_captures
87 #  error "__cpp_init_captures"
88 #elif __cpp_init_captures != 201304
89 #  error "__cpp_init_captures != 201304"
90 #endif
92 #ifndef __cpp_generic_lambdas
93 #  error "__cpp_generic_lambdas"
94 #elif __cpp_generic_lambdas != 201304
95 #  error "__cpp_generic_lambdas != 201304"
96 #endif
98 //  TODO: Change 200704 to 201304 when C++14 constexpr goes in.
99 #ifndef __cpp_constexpr
100 #  error "__cpp_constexpr"
101 #elif __cpp_constexpr != 200704
102 #  error "__cpp_constexpr != 200704"
103 #endif
105 #ifndef __cpp_decltype_auto
106 #  error "__cpp_decltype_auto"
107 #elif __cpp_decltype_auto != 201304
108 #  error "__cpp_decltype_auto != 201304"
109 #endif
111 #ifndef __cpp_return_type_deduction
112 #  error "__cpp_return_type_deduction"
113 #elif __cpp_return_type_deduction != 201304
114 #  error "__cpp_return_type_deduction != 201304"
115 #endif
117 #ifndef __cpp_runtime_arrays
118 #  error "__cpp_runtime_arrays"
119 #elif __cpp_runtime_arrays != 201304
120 #  error "__cpp_runtime_arrays != 201304"
121 #endif
123 //  Aggregate initializers not in yet.
124 #ifdef __cpp_aggregate_nsdmi
125 #  error "__cpp_aggregate_nsdmi"
126 #endif
128 #ifndef __cpp_variable_templates
129 #  error "__cpp_variable_templates"
130 #elif __cpp_variable_templates != 201304
131 #  error "__cpp_variable_templates != 201304"
132 #endif
134 #ifndef __cpp_digit_separators
135 #  error "__cpp_digit_separators"
136 #elif __cpp_digit_separators != 201309
137 #  error "__cpp_digit_separators != 201309"
138 #endif
140 #ifndef __cpp_attribute_deprecated
141 #  error "__cpp_attribute_deprecated"
142 #elif __cpp_attribute_deprecated != 201309
143 #  error "__cpp_attribute_deprecated != 201309"
144 #endif
146 //  Sized deallocation not in yet.
147 #ifdef __cpp_sized_deallocation
148 #  error "__cpp_sized_deallocation"
149 #endif
151 // Begin include checks.
153 //  Check for __has_include macro.
154 #ifndef __has_include
155 #  error "__has_include"
156 #endif
158 //  Quoted complex.h should find at least the bracket version (use operator).
159 #if __has_include__ "complex.h"
160 #else
161 #  error "complex.h"
162 #endif
164 //  Try known bracket header (use operator).
165 #if __has_include__(<complex>)
166 #else
167 #  error "<complex>"
168 #endif
170 //  Define and use a macro to invoke the operator.
171 #define sluggo(TXT) __has_include__(TXT)
173 #if sluggo(<complex>)
174 #else
175 #  error "<complex>"
176 #endif
178 #if ! sluggo(<complex>)
179 #  error "<complex>"
180 #else
181 #endif
183 //  Quoted complex.h should find at least the bracket version.
184 #if __has_include("complex.h")
185 #else
186 #  error "complex.h"
187 #endif
189 //  Try known local quote header.
190 #if __has_include("complex_literals.h")
191 #else
192 #  error "\"complex_literals.h\""
193 #endif
195 //  Try nonexistent bracket header.
196 #if __has_include(<stuff>)
197 #  error "<stuff>"
198 #else
199 #endif
201 //  Try nonexistent quote header.
202 #if __has_include("phlegm")
203 #  error "\"phlegm\""
204 #else
205 #endif
207 //  Test __has_include_next.
208 #if __has_include("phoobhar.h")
209 #  include "phoobhar.h"
210 #else
211 #  error "__has_include(\"phoobhar.h\")"
212 #endif
214 //  Try a macro.
215 #define COMPLEX_INC "complex.h"
216 #if __has_include(COMPLEX_INC)
217 #else
218 #  error COMPLEX_INC
219 #endif
221 //  Realistic use of __has_include.
222 #if __has_include(<array>)
223 #  define STD_ARRAY 1
224 #  include <array>
225   template<typename _Tp, size_t _Num>
226     using array = std::array<_Tp, _Num>;
227 #elif __has_include(<tr1/array>)
228 #  define TR1_ARRAY 1
229 #  include <tr1/array>
230   template<typename _Tp, size_t _Num>
231     typedef std::tr1::array<_Tp, _Num> array;
232 #endif