136db4898SMarshall Clow //===----------------------------------------------------------------------===// 236db4898SMarshall Clow // 336db4898SMarshall Clow // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 436db4898SMarshall Clow // See https://llvm.org/LICENSE.txt for license information. 536db4898SMarshall Clow // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 636db4898SMarshall Clow // 736db4898SMarshall Clow //===----------------------------------------------------------------------===// 836db4898SMarshall Clow 931cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14 1036db4898SMarshall Clow // <optional> 1136db4898SMarshall Clow 1236db4898SMarshall Clow // T shall be an object type other than cv in_place_t or cv nullopt_t 1336db4898SMarshall Clow // and shall satisfy the Cpp17Destructible requirements. 1436db4898SMarshall Clow // Note: array types do not satisfy the Cpp17Destructible requirements. 1536db4898SMarshall Clow 1636db4898SMarshall Clow #include <optional> 1736db4898SMarshall Clow #include <type_traits> 1836db4898SMarshall Clow #include <cassert> 1936db4898SMarshall Clow 2036db4898SMarshall Clow #include "test_macros.h" 2136db4898SMarshall Clow 2236db4898SMarshall Clow struct NonDestructible { ~NonDestructible() = delete; }; 2336db4898SMarshall Clow main(int,char **)2436db4898SMarshall Clowint main(int, char**) 2536db4898SMarshall Clow { 2636db4898SMarshall Clow { 27*76476efdSMuhammad Usman Shahid std::optional<char &> o1; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with a reference type is ill-formed}} 28*76476efdSMuhammad Usman Shahid std::optional<NonDestructible> o2; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with a non-destructible type is ill-formed}} 29*76476efdSMuhammad Usman Shahid std::optional<char[20]> o3; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with an array type is ill-formed}} 3036db4898SMarshall Clow } 3136db4898SMarshall Clow 3236db4898SMarshall Clow { 33*76476efdSMuhammad Usman Shahid std::optional< std::in_place_t> o1; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with in_place_t is ill-formed}} 34*76476efdSMuhammad Usman Shahid std::optional<const std::in_place_t> o2; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with in_place_t is ill-formed}} 35*76476efdSMuhammad Usman Shahid std::optional< volatile std::in_place_t> o3; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with in_place_t is ill-formed}} 36*76476efdSMuhammad Usman Shahid std::optional<const volatile std::in_place_t> o4; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with in_place_t is ill-formed}} 3736db4898SMarshall Clow } 3836db4898SMarshall Clow 3936db4898SMarshall Clow { 40*76476efdSMuhammad Usman Shahid std::optional< std::nullopt_t> o1; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with nullopt_t is ill-formed}} 41*76476efdSMuhammad Usman Shahid std::optional<const std::nullopt_t> o2; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with nullopt_t is ill-formed}} 42*76476efdSMuhammad Usman Shahid std::optional< volatile std::nullopt_t> o3; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with nullopt_t is ill-formed}} 43*76476efdSMuhammad Usman Shahid std::optional<const volatile std::nullopt_t> o4; // expected-error-re@optional:* {{{{(static_assert|static assertion)}} failed{{.*}}instantiation of optional with nullopt_t is ill-formed}} 4436db4898SMarshall Clow } 4536db4898SMarshall Clow 4636db4898SMarshall Clow return 0; 4736db4898SMarshall Clow } 48