• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 // <optional>
12 
13 // T shall be an object type and shall satisfy the requirements of Destructible
14 
15 #include <optional>
16 
17 using std::optional;
18 
19 struct X
20 {
21 private:
~XX22     ~X() {}
23 };
24 
main()25 int main()
26 {
27     using std::optional;
28     {
29         // expected-error-re@optional:* 2 {{static_assert failed{{.*}} "instantiation of optional with a reference type is ill-formed}}
30         optional<int&> opt1;
31         optional<int&&> opt2;
32     }
33     {
34         // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed"}}
35         optional<X> opt3;
36     }
37     {
38         // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-object type is undefined behavior"}}
39         // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed}}
40         optional<void()> opt4;
41     }
42     {
43         // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-object type is undefined behavior"}}
44         // expected-error-re@optional:* {{static_assert failed{{.*}} "instantiation of optional with a non-destructible type is ill-formed}}
45         // expected-error@optional:* 1+ {{cannot form a reference to 'void'}}
46         optional<const void> opt4;
47     }
48     // FIXME these are garbage diagnostics that Clang should not produce
49     // expected-error@optional:* 0+ {{is not a base class}}
50 }
51