summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/any
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-16 01:43:43 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-16 01:43:43 +0000
commit9c737fddba93bce4127dbed4fa2a4440414c1afb (patch)
treed4f62139b87579a3939e0f20b38681b48fa09786 /libcxx/test/std/utilities/any
parente9cdb24f679cba41caa596c28309efbf6da9e786 (diff)
downloadbcm5719-llvm-9c737fddba93bce4127dbed4fa2a4440414c1afb.tar.gz
bcm5719-llvm-9c737fddba93bce4127dbed4fa2a4440414c1afb.zip
Update issue status for LWG 2768 and 2769
llvm-svn: 284321
Diffstat (limited to 'libcxx/test/std/utilities/any')
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp66
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp8
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp4
-rw-r--r--libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp36
4 files changed, 72 insertions, 42 deletions
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
new file mode 100644
index 00000000000..07578a28e82
--- /dev/null
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <any>
+
+// template <class ValueType>
+// ValueType any_cast(any &&);
+
+// Try and use the rvalue any_cast to cast to an lvalue reference
+
+#include <any>
+
+struct TestType {};
+using std::any;
+using std::any_cast;
+
+void test_const_lvalue_cast_request_non_const_lvalue()
+{
+ const any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{binding value of type 'const TestType' to reference to type 'TestType' drops 'const' qualifier}}
+ any_cast<TestType &>(a); // expected-note {{requested here}}
+
+ const any a2(42);
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}}
+ any_cast<int&>(a2); // expected-note {{requested here}}
+}
+
+void test_lvalue_any_cast_request_rvalue()
+{
+ any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
+ any_cast<TestType &&>(a); // expected-note {{requested here}}
+
+ any a2(42);
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
+ any_cast<int&&>(a2); // expected-note {{requested here}}
+}
+
+void test_rvalue_any_cast_request_lvalue()
+{
+ any a;
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}}
+ any_cast<TestType &>(std::move(a)); // expected-note {{requested here}}
+
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
+ // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}}
+ any_cast<int&>(42);
+}
+
+int main()
+{
+ test_const_lvalue_cast_request_non_const_lvalue();
+ test_lvalue_any_cast_request_rvalue();
+ test_rvalue_any_cast_request_lvalue();
+}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
index 59294e78085..3f6955a8cbc 100644
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
@@ -29,18 +29,18 @@ int main()
any a;
// expected-error@any:* {{binding value of type 'const TestType' to reference to type 'TestType' drops 'const' qualifier}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &>(static_cast<any const&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{cannot cast from lvalue of type 'const TestType' to rvalue reference type 'TestType &&'; types are not compatible}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &&>(static_cast<any const&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{binding value of type 'const TestType2' to reference to type 'TestType2' drops 'const' qualifier}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &>(static_cast<any const&&>(a)); // expected-note {{requested here}}
// expected-error@any:* {{cannot cast from lvalue of type 'const TestType2' to rvalue reference type 'TestType2 &&'; types are not compatible}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &&>(static_cast<any const&&>(a)); // expected-note {{requested here}}
}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
index 13e1a556086..ed4b96d644d 100644
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
@@ -42,11 +42,11 @@ struct no_move {
int main() {
any a;
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
// expected-error@any:* {{static_cast from 'no_copy' to 'no_copy' uses deleted function}}
any_cast<no_copy>(static_cast<any&>(a)); // expected-note {{requested here}}
- // expected-error@any:* {{static_assert failed "ValueType is required to be a reference or a CopyConstructible type"}}
+ // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
// expected-error@any:* {{static_cast from 'const no_copy' to 'no_copy' uses deleted function}}
any_cast<no_copy>(static_cast<any const&>(a)); // expected-note {{requested here}}
diff --git a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp
deleted file mode 100644
index 76df14c33aa..00000000000
--- a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// <any>
-
-// template <class ValueType>
-// ValueType any_cast(any &&);
-
-// Try and use the rvalue any_cast to cast to an lvalue reference
-
-#include <any>
-
-struct TestType {};
-
-int main()
-{
- using std::any;
- using std::any_cast;
-
- any a;
- // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}}
- any_cast<TestType &>(std::move(a)); // expected-note {{requested here}}
-
- // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}}
- any_cast<int&>(42);
-}
OpenPOWER on IntegriCloud