1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14 10 // <optional> 11 12 // T shall be an object type and shall satisfy the requirements of Destructible 13 14 #include <optional> 15 16 using std::optional; 17 18 struct X 19 { 20 private: 21 ~X() {} 22 }; 23 24 int main(int, char**) 25 { 26 using std::optional; 27 { 28 // expected-error-re@optional:* 2 {{static_assert failed{{.*}} "instantiation of optional with a reference type is ill-formed}} 29 optional<int&> opt1; 30 optional<int&&> opt2; 31 } 32 { 33 // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed"}} 34 optional<X> opt3; 35 } 36 { 37 // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-object type is undefined behavior"}} 38 // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed}} 39 optional<void()> opt4; 40 } 41 { 42 // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-object type is undefined behavior"}} 43 // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed}} 44 // expected-error@optional:* 1+ {{cannot form a reference to 'void'}} 45 optional<const void> opt4; 46 } 47 // FIXME these are garbage diagnostics that Clang should not produce 48 // expected-error@optional:* 0+ {{is not a base class}} 49 50 return 0; 51 } 52