From 9c737fddba93bce4127dbed4fa2a4440414c1afb Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 16 Oct 2016 01:43:43 +0000 Subject: [PATCH] Update issue status for LWG 2768 and 2769 llvm-svn: 284321 --- libcxx/include/any | 9 ++- ...ny_cast_request_invalid_value_category.fail.cpp | 66 ++++++++++++++++++++++ .../any.cast/const_correctness.fail.cpp | 8 +-- .../any.cast/not_copy_constructible.fail.cpp | 4 +- .../rvalue_any_cast_request_lvalue.fail.cpp | 36 ------------ libcxx/www/upcoming_meeting.html | 10 ++-- 6 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp delete mode 100644 libcxx/test/std/utilities/any/any.nonmembers/any.cast/rvalue_any_cast_request_lvalue.fail.cpp diff --git a/libcxx/include/any b/libcxx/include/any index 69fdbdd..8fe9e8f 100644 --- a/libcxx/include/any +++ b/libcxx/include/any @@ -579,7 +579,8 @@ _ValueType any_cast(any const & __v) { using _RawValueType = __uncvref_t<_ValueType>; static_assert(is_constructible<_ValueType, _RawValueType const &>::value, - "ValueType is required to be a reference or a CopyConstructible type"); + "ValueType is required to be a const lvalue reference " + "or a CopyConstructible type"); auto __tmp = _VSTD::any_cast>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); @@ -592,7 +593,8 @@ _ValueType any_cast(any & __v) { using _RawValueType = __uncvref_t<_ValueType>; static_assert(is_constructible<_ValueType, _RawValueType &>::value, - "ValueType is required to be a reference or a CopyConstructible type"); + "ValueType is required to be an lvalue reference " + "or a CopyConstructible type"); auto __tmp = _VSTD::any_cast<_RawValueType>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); @@ -605,7 +607,8 @@ _ValueType any_cast(any && __v) { using _RawValueType = __uncvref_t<_ValueType>; static_assert(is_constructible<_ValueType, _RawValueType>::value, - "ValueType is required to be an rvalue reference or a CopyConstructible type"); + "ValueType is required to be an rvalue reference " + "or a CopyConstructible type"); auto __tmp = _VSTD::any_cast<_RawValueType>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); 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 0000000..07578a2 --- /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 + +// + +// template +// ValueType any_cast(any &&); + +// Try and use the rvalue any_cast to cast to an lvalue reference + +#include + +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(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(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(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(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(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(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 59294e7..3f6955a 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(static_cast(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(static_cast(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(static_cast(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(static_cast(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 13e1a55..ed4b96d 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(static_cast(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(static_cast(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 76df14c..0000000 --- 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 - -// - -// template -// ValueType any_cast(any &&); - -// Try and use the rvalue any_cast to cast to an lvalue reference - -#include - -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(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(42); -} diff --git a/libcxx/www/upcoming_meeting.html b/libcxx/www/upcoming_meeting.html index 4607bb3..ec447b1 100644 --- a/libcxx/www/upcoming_meeting.html +++ b/libcxx/www/upcoming_meeting.html @@ -127,8 +127,8 @@ 2760non-const basic_string::data should not invalidate iteratorsIssaquahNothing to do 2765Did LWG 1123 go too far?Issaquah 2767not_fn call_wrapper can form invalid typesIssaquah - 2768any_cast and move semanticsIssaquah - + 2768any_cast and move semanticsIssaquahResolved by LWG 2769 + 2769Redundant const in the return type of any_cast(const any&)IssaquahImplemented in trunk 2771Broken Effects of some basic_string::compare functions in terms of basic_string_viewIssaquahWe already do this 2773Making std::ignore constexprIssaquah 2777basic_string_view::copy should use char_traits::copyIssaquahPatch Ready @@ -205,8 +205,10 @@
  • 2760 - This is just wording cleanup; no code or test changes needed.
  • 2765 - is this just wording cleanup????? I don't think this actually requires code changes.
  • 2767 -
  • -
  • 2768 - std::any
  • - +
  • 2768 - std::any: There is no PR for this issue. It is resolved by LWG 2769.
  • +
  • 2769 - std::any: The PR looks good except that + remove_reference_t<remove_cv_t<T>> should read + remove_cv_t<remove_reference_t<T>>.
  • 2771 - We already do this.
  • 2773 -
  • 2777 - Patch ready; existing tests should suffice
  • -- 2.7.4