| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
// { dg-add-options no_pch } |
| 3 |
|
| 4 |
#include <version> |
| 5 |
|
| 6 |
#ifndef __cpp_lib_optional |
| 7 |
# error "Feature test macro for optional is missing in <version>" |
| 8 |
#elif __cplusplus == 201703L && __cpp_lib_optional != 201606L |
| 9 |
# error "Feature test macro for optional has wrong value for C++17 in <version>" |
| 10 |
#elif __cplusplus == 202002L && __cpp_lib_optional != 202106L |
| 11 |
# error "Feature test macro for optional has wrong value for C++20 in <version>" |
| 12 |
#elif __cplusplus > 202002L && __cpp_lib_optional != 202110L |
| 13 |
# error "Feature test macro for optional has wrong value for C++23 in <version>" |
| 14 |
#endif |
| 15 |
|
| 16 |
#if __cplusplus >= 202302L |
| 17 |
#ifndef __cpp_lib_freestanding_optional |
| 18 |
# error "Feature test macro for freestanding std::optional is missing in <version>" |
| 19 |
#elif __cpp_lib_freestanding_optional < 202311L |
| 20 |
# error "Feature test macro for freestanding std::optional has wrong value in <version>" |
| 21 |
#endif |
| 22 |
#endif |
| 23 |
|
| 24 |
#undef __cpp_lib_optional |
| 25 |
#undef __cpp_lib_freestanding_optional |
| 26 |
#include <optional> |
| 27 |
|
| 28 |
#if __cplusplus >= 202302L |
| 29 |
#ifndef __cpp_lib_freestanding_optional |
| 30 |
# error "Feature test macro for freestanding std::optional is missing in <optional>" |
| 31 |
#elif __cpp_lib_freestanding_optional < 202311L |
| 32 |
# error "Feature test macro for freestanding std::optional has wrong value in <optional>" |
| 33 |
#endif |
| 34 |
#endif |