| 1 |
// { dg-options "-std=c++14 -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_unicode_characters |
| 21 |
# error "__cpp_unicode_characters" |
| 22 |
#elif __cpp_unicode_characters != 200704 |
| 23 |
# error "__cpp_unicode_characters != 200704" |
| 24 |
#endif |
| 25 |
|
| 26 |
#ifndef __cpp_raw_strings |
| 27 |
# error "__cpp_raw_strings" |
| 28 |
#elif __cpp_raw_strings != 200710 |
| 29 |
# error "__cpp_raw_strings != 200710" |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifndef __cpp_unicode_literals |
| 33 |
# error "__cpp_unicode_literals" |
| 34 |
#elif __cpp_unicode_literals != 200710 |
| 35 |
# error "__cpp_unicode_literals != 200710" |
| 36 |
#endif |
| 37 |
|
| 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 |
| 43 |
|
| 44 |
#ifndef __cpp_lambdas |
| 45 |
# error "__cpp_lambdas" |
| 46 |
#elif __cpp_lambdas != 200907 |
| 47 |
# error "__cpp_lambdas != 200907" |
| 48 |
#endif |
| 49 |
|
| 50 |
#ifndef __cpp_range_based_for |
| 51 |
# error "__cpp_range_based_for" |
| 52 |
#elif __cpp_range_based_for < 200907 |
| 53 |
# error "__cpp_range_based_for < 200907" |
| 54 |
#endif |
| 55 |
|
| 56 |
#ifndef __cpp_static_assert |
| 57 |
# error "__cpp_static_assert" |
| 58 |
#elif __cpp_static_assert != 200410 |
| 59 |
# error "__cpp_static_assert != 200410" |
| 60 |
#endif |
| 61 |
|
| 62 |
#ifndef __cpp_decltype |
| 63 |
# error "__cpp_decltype" |
| 64 |
#elif __cpp_decltype != 200707 |
| 65 |
# error "__cpp_decltype != 200707" |
| 66 |
#endif |
| 67 |
|
| 68 |
#ifndef __cpp_attributes |
| 69 |
# error "__cpp_attributes" |
| 70 |
#elif __cpp_attributes != 200809 |
| 71 |
# error "__cpp_attributes != 200809" |
| 72 |
#endif |
| 73 |
|
| 74 |
#ifndef __cpp_rvalue_references |
| 75 |
# error "__cpp_rvalue_references" |
| 76 |
#elif __cpp_rvalue_references != 200610 |
| 77 |
# error "__cpp_rvalue_references != 200610" |
| 78 |
#endif |
| 79 |
|
| 80 |
#ifndef __cpp_variadic_templates |
| 81 |
# error "__cpp_variadic_templates" |
| 82 |
#elif __cpp_variadic_templates != 200704 |
| 83 |
# error "__cpp_variadic_templates != 200704" |
| 84 |
#endif |
| 85 |
|
| 86 |
#ifndef __cpp_initializer_lists |
| 87 |
# error "__cpp_initializer_lists" |
| 88 |
#elif __cpp_initializer_lists != 200806 |
| 89 |
# error "__cpp_initializer_lists != 200806" |
| 90 |
#endif |
| 91 |
|
| 92 |
#ifndef __cpp_delegating_constructors |
| 93 |
# error "__cpp_delegating_constructors" |
| 94 |
#elif __cpp_delegating_constructors != 200604 |
| 95 |
# error "__cpp_delegating_constructors != 200604" |
| 96 |
#endif |
| 97 |
|
| 98 |
#ifndef __cpp_nsdmi |
| 99 |
# error "__cpp_nsdmi" |
| 100 |
#elif __cpp_nsdmi != 200809 |
| 101 |
# error "__cpp_nsdmi != 200809" |
| 102 |
#endif |
| 103 |
|
| 104 |
#ifndef __cpp_inheriting_constructors |
| 105 |
# error "__cpp_inheriting_constructors" |
| 106 |
#elif __cpp_inheriting_constructors!= 201511 |
| 107 |
# error "__cpp_inheriting_constructors != 201511" |
| 108 |
#endif |
| 109 |
|
| 110 |
#ifndef __cpp_ref_qualifiers |
| 111 |
# error "__cpp_ref_qualifiers" |
| 112 |
#elif __cpp_ref_qualifiers != 200710 |
| 113 |
# error "__cpp_ref_qualifiers != 200710" |
| 114 |
#endif |
| 115 |
|
| 116 |
#ifndef __cpp_alias_templates |
| 117 |
# error "__cpp_alias_templates" |
| 118 |
#elif __cpp_alias_templates != 200704 |
| 119 |
# error "__cpp_alias_templates != 200704" |
| 120 |
#endif |
| 121 |
|
| 122 |
#ifndef __cpp_threadsafe_static_init |
| 123 |
# error "__cpp_threadsafe_static_init" |
| 124 |
#elif __cpp_threadsafe_static_init != 200806 |
| 125 |
# error "__cpp_threadsafe_static_init != 200806" |
| 126 |
#endif |
| 127 |
|
| 128 |
// C++14 features: |
| 129 |
|
| 130 |
#ifndef __cpp_binary_literals |
| 131 |
# error "__cpp_binary_literals" |
| 132 |
#elif __cpp_binary_literals != 201304 |
| 133 |
# error "__cpp_binary_literals != 201304" |
| 134 |
#endif |
| 135 |
|
| 136 |
#ifndef __cpp_init_captures |
| 137 |
# error "__cpp_init_captures" |
| 138 |
#elif __cpp_init_captures != 201304 |
| 139 |
# error "__cpp_init_captures != 201304" |
| 140 |
#endif |
| 141 |
|
| 142 |
#ifndef __cpp_generic_lambdas |
| 143 |
# error "__cpp_generic_lambdas" |
| 144 |
#elif __cpp_generic_lambdas != 201304 |
| 145 |
# error "__cpp_generic_lambdas != 201304" |
| 146 |
#endif |
| 147 |
|
| 148 |
#ifndef __cpp_constexpr |
| 149 |
# error "__cpp_constexpr" |
| 150 |
#elif __cpp_constexpr != 201304 |
| 151 |
# error "__cpp_constexpr != 201304" |
| 152 |
#endif |
| 153 |
|
| 154 |
#ifndef __cpp_decltype_auto |
| 155 |
# error "__cpp_decltype_auto" |
| 156 |
#elif __cpp_decltype_auto != 201304 |
| 157 |
# error "__cpp_decltype_auto != 201304" |
| 158 |
#endif |
| 159 |
|
| 160 |
#ifndef __cpp_return_type_deduction |
| 161 |
# error "__cpp_return_type_deduction" |
| 162 |
#elif __cpp_return_type_deduction != 201304 |
| 163 |
# error "__cpp_return_type_deduction != 201304" |
| 164 |
#endif |
| 165 |
|
| 166 |
#ifndef __cpp_aggregate_nsdmi |
| 167 |
# error "__cpp_aggregate_nsdmi" |
| 168 |
#elif __cpp_aggregate_nsdmi != 201304 |
| 169 |
# error "__cpp_aggregate_nsdmi != 201304" |
| 170 |
#endif |
| 171 |
|
| 172 |
#ifndef __cpp_variable_templates |
| 173 |
# error "__cpp_variable_templates" |
| 174 |
#elif __cpp_variable_templates != 201304 |
| 175 |
# error "__cpp_variable_templates != 201304" |
| 176 |
#endif |
| 177 |
|
| 178 |
#ifndef __cpp_digit_separators |
| 179 |
# error "__cpp_digit_separators" |
| 180 |
#elif __cpp_digit_separators != 201309 |
| 181 |
# error "__cpp_digit_separators != 201309" |
| 182 |
#endif |
| 183 |
|
| 184 |
#ifndef __cpp_sized_deallocation |
| 185 |
# error "__cpp_sized_deallocation" |
| 186 |
#elif __cpp_sized_deallocation != 201309 |
| 187 |
# error "__cpp_sized_deallocation != 201309" |
| 188 |
#endif |
| 189 |
|
| 190 |
// GNU VLA support: |
| 191 |
|
| 192 |
#ifndef __cpp_runtime_arrays |
| 193 |
# error "__cpp_runtime_arrays" |
| 194 |
#elif __cpp_runtime_arrays != 198712 |
| 195 |
# error "__cpp_runtime_arrays != 198712" |
| 196 |
#endif |
| 197 |
|
| 198 |
// C++11 attributes: |
| 199 |
|
| 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 |
| 209 |
|
| 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 |
| 220 |
|
| 221 |
// C++14 attributes: |
| 222 |
|
| 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 |
| 232 |
|
| 233 |
// Include checks: |
| 234 |
|
| 235 |
// Check for __has_include macro. |
| 236 |
#ifndef __has_include |
| 237 |
# error "__has_include" |
| 238 |
#endif |
| 239 |
|
| 240 |
// Try known bracket header (use operator). |
| 241 |
#if __has_include (<complex>) |
| 242 |
#else |
| 243 |
# error "<complex>" |
| 244 |
#endif |
| 245 |
|
| 246 |
// Define and use a macro to invoke the operator. |
| 247 |
#define sluggo(TXT) __has_include(TXT) |
| 248 |
|
| 249 |
#if sluggo(<complex>) |
| 250 |
#else |
| 251 |
# error "<complex>" |
| 252 |
#endif |
| 253 |
|
| 254 |
#if ! sluggo(<complex>) |
| 255 |
# error "<complex>" |
| 256 |
#else |
| 257 |
#endif |
| 258 |
|
| 259 |
// Quoted complex.h should find at least the bracket version. |
| 260 |
#if __has_include("complex.h") |
| 261 |
#else |
| 262 |
# error "complex.h" |
| 263 |
#endif |
| 264 |
|
| 265 |
// Try known local quote header. |
| 266 |
#if __has_include("complex_literals.h") |
| 267 |
#else |
| 268 |
# error "\"complex_literals.h\"" |
| 269 |
#endif |
| 270 |
|
| 271 |
// Try nonexistent bracket header. |
| 272 |
#if __has_include(<stuff>) |
| 273 |
# error "<stuff>" |
| 274 |
#else |
| 275 |
#endif |
| 276 |
|
| 277 |
// Try nonexistent quote header. |
| 278 |
#if __has_include("phlegm") |
| 279 |
# error "\"phlegm\"" |
| 280 |
#else |
| 281 |
#endif |
| 282 |
|
| 283 |
// Test __has_include_next. |
| 284 |
#if __has_include("phoobhar.h") |
| 285 |
# include "phoobhar.h" |
| 286 |
#else |
| 287 |
# error "__has_include(\"phoobhar.h\")" |
| 288 |
#endif |
| 289 |
|
| 290 |
// Try a macro. |
| 291 |
#define COMPLEX_INC "complex.h" |
| 292 |
#if __has_include(COMPLEX_INC) |
| 293 |
#else |
| 294 |
# error COMPLEX_INC |
| 295 |
#endif |
| 296 |
|
| 297 |
// Realistic use of __has_include. |
| 298 |
#if __has_include(<array>) |
| 299 |
# define STD_ARRAY 1 |
| 300 |
# include <array> |
| 301 |
template<typename _Tp, std::size_t _Num> |
| 302 |
using array = std::array<_Tp, _Num>; |
| 303 |
#elif __has_include(<tr1/array>) |
| 304 |
# define TR1_ARRAY 1 |
| 305 |
# include <tr1/array> |
| 306 |
template<typename _Tp, std::size_t _Num> |
| 307 |
typedef std::tr1::array<_Tp, _Num> array; |
| 308 |
#endif |