aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-12 06:45:11 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-12 06:45:11 +0000
commit6ee4001cc957acac39181b68193e1414c3163698 (patch)
tree6f4a8a05e89e454e08b4385f522b0d84b9e64d7a /libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
parent49a278fb6ddd123d68ddbe7cedbedff92cd433c1 (diff)
Add <optional> header.
This patch is largely thanks to Casey Carter @ Microsoft. He did the initial work of porting our experimental implementation and tests over to namespace std. llvm-svn: 283977
Diffstat (limited to 'libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp')
-rw-r--r--libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp b/libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
new file mode 100644
index 000000000000..8a2c77af0ec1
--- /dev/null
+++ b/libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <optional>
+
+using std::optional;
+
+struct X
+{
+private:
+ ~X() {}
+};
+
+int main()
+{
+ using std::optional;
+ {
+ // expected-error@optional:* 2 {{static_assert failed "instantiation of optional with a reference type is ill-formed}}
+ optional<int&> opt1;
+ optional<int&&> opt2;
+ }
+ {
+ // expected-error@optional:* {{static_assert failed "instantiation of optional with a non-destructible type is ill-formed"}}
+ optional<X> opt3;
+ }
+ {
+ // expected-error@optional:* {{static_assert failed "instantiation of optional with a non-object type is undefined behavior"}}
+ // expected-error@optional:* {{static_assert failed "instantiation of optional with a non-destructible type is ill-formed}}
+ optional<void()> opt4;
+ }
+ {
+ // expected-error@optional:* {{static_assert failed "instantiation of optional with a non-object type is undefined behavior"}}
+ // expected-error@optional:* {{static_assert failed "instantiation of optional with a non-destructible type is ill-formed}}
+ // expected-error@optional:* 1+ {{cannot form a reference to 'void'}}
+ optional<const void> opt4;
+ }
+ // FIXME these are garbage diagnostics that Clang should not produce
+ // expected-error@optional:* 0+ {{is not a base class}}
+}