diff options
| author | Zhihao Yuan <zy@miator.net> | 2019-06-19 07:11:08 +0000 |
|---|---|---|
| committer | Zhihao Yuan <zy@miator.net> | 2019-06-19 07:11:08 +0000 |
| commit | 3f0ae625ebfa41452cc5d118ce26f5e9594412a3 (patch) | |
| tree | d6db34f0999f4a162129f823ef28e88572aac15f /libcxx/test/std | |
| parent | 58dbe47b9c64bafcc8b430e8bfea92f7fe641c8e (diff) | |
| download | bcm5719-llvm-3f0ae625ebfa41452cc5d118ce26f5e9594412a3.tar.gz bcm5719-llvm-3f0ae625ebfa41452cc5d118ce26f5e9594412a3.zip | |
[libc++] Revert r363692 which implements P0608R3
The change caused a large number of compiler failures in
Google's codebase. People need time to evaluate the impact.
llvm-svn: 363764
Diffstat (limited to 'libcxx/test/std')
4 files changed, 3 insertions, 207 deletions
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp index b2b53d6c6ea..02498b1acde 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp @@ -22,7 +22,6 @@ #include <string> #include <type_traits> #include <variant> -#include <memory> #include "test_macros.h" #include "variant_test_helpers.hpp" @@ -123,7 +122,7 @@ void test_T_assignment_noexcept() { void test_T_assignment_sfinae() { { - using V = std::variant<long, long long>; + using V = std::variant<long, unsigned>; static_assert(!std::is_assignable<V, int>::value, "ambiguous"); } { @@ -134,31 +133,6 @@ void test_T_assignment_sfinae() { using V = std::variant<std::string, void *>; static_assert(!std::is_assignable<V, int>::value, "no matching operator="); } - { - using V = std::variant<std::string, float>; - static_assert(!std::is_assignable<V, int>::value, "no matching operator="); - } - { - using V = std::variant<std::unique_ptr<int>, bool>; - static_assert(!std::is_assignable<V, std::unique_ptr<char>>::value, - "no explicit bool in operator="); - struct X { - operator void*(); - }; - static_assert(!std::is_assignable<V, X>::value, - "no boolean conversion in operator="); - static_assert(!std::is_assignable<V, std::false_type>::value, - "no converted to bool in operator="); - } - { - struct X {}; - struct Y { - operator X(); - }; - using V = std::variant<X>; - static_assert(std::is_assignable<V, Y>::value, - "regression on user-defined conversions in operator="); - } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { using V = std::variant<int, int &&>; @@ -187,37 +161,6 @@ void test_T_assignment_basic() { assert(v.index() == 1); assert(std::get<1>(v) == 43); } - { - std::variant<unsigned, long> v; - v = 42; - assert(v.index() == 1); - assert(std::get<1>(v) == 42); - v = 43u; - assert(v.index() == 0); - assert(std::get<0>(v) == 43); - } - { - std::variant<std::string, bool> v = true; - v = "bar"; - assert(v.index() == 0); - assert(std::get<0>(v) == "bar"); - } - { - std::variant<bool, std::unique_ptr<int>> v; - v = nullptr; - assert(v.index() == 1); - assert(std::get<1>(v) == nullptr); - } - { - std::variant<bool volatile, int> v = 42; - v = false; - assert(v.index() == 0); - assert(!std::get<0>(v)); - bool lvt = true; - v = lvt; - assert(v.index() == 0); - assert(std::get<0>(v)); - } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { using V = std::variant<int &, int &&, long>; diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.fail.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.fail.cpp deleted file mode 100644 index d5f370d2720..00000000000 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.fail.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// <variant> - -// template <class ...Types> class variant; - -// template <class T> -// variant& operator=(T&&) noexcept(see below); - -#include <variant> -#include <string> -#include <memory> - -int main(int, char**) -{ - std::variant<int, int> v1; - std::variant<long, long long> v2; - std::variant<char> v3; - v1 = 1; // expected-error {{no viable overloaded '='}} - v2 = 1; // expected-error {{no viable overloaded '='}} - v3 = 1; // expected-error {{no viable overloaded '='}} - - std::variant<std::string, float> v4; - std::variant<std::string, double> v5; - std::variant<std::string, bool> v6; - v4 = 1; // expected-error {{no viable overloaded '='}} - v5 = 1; // expected-error {{no viable overloaded '='}} - v6 = 1; // expected-error {{no viable overloaded '='}} - - std::variant<int, bool> v7; - std::variant<int, bool const> v8; - std::variant<int, bool volatile> v9; - v7 = "meow"; // expected-error {{no viable overloaded '='}} - v8 = "meow"; // expected-error {{no viable overloaded '='}} - v9 = "meow"; // expected-error {{no viable overloaded '='}} - - std::variant<bool> v10; - std::variant<bool> v11; - std::variant<bool> v12; - v10 = std::true_type(); // expected-error {{no viable overloaded '='}} - v11 = std::unique_ptr<char>(); // expected-error {{no viable overloaded '='}} - v12 = nullptr; // expected-error {{no viable overloaded '='}} -} diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp index 40fa20b4f5e..73bd2c6283d 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp @@ -20,8 +20,8 @@ #include <string> #include <type_traits> #include <variant> -#include <memory> +#include "test_convertible.hpp" #include "test_macros.h" #include "variant_test_helpers.hpp" @@ -39,8 +39,6 @@ struct NoThrowT { struct AnyConstructible { template <typename T> AnyConstructible(T&&) {} }; struct NoConstructible { NoConstructible() = delete; }; -template <class T> -struct RValueConvertibleFrom { RValueConvertibleFrom(T&&) {} }; void test_T_ctor_noexcept() { { @@ -55,7 +53,7 @@ void test_T_ctor_noexcept() { void test_T_ctor_sfinae() { { - using V = std::variant<long, long long>; + using V = std::variant<long, unsigned>; static_assert(!std::is_constructible<V, int>::value, "ambiguous"); } { @@ -68,32 +66,6 @@ void test_T_ctor_sfinae() { "no matching constructor"); } { - using V = std::variant<std::string, float>; - static_assert(!std::is_constructible<V, int>::value, - "no matching constructor"); - } - { - using V = std::variant<std::unique_ptr<int>, bool>; - static_assert(!std::is_constructible<V, std::unique_ptr<char>>::value, - "no explicit bool in constructor"); - struct X { - operator void*(); - }; - static_assert(!std::is_constructible<V, X>::value, - "no boolean conversion in constructor"); - static_assert(!std::is_constructible<V, std::false_type>::value, - "no converted to bool in constructor"); - } - { - struct X {}; - struct Y { - operator X(); - }; - using V = std::variant<X>; - static_assert(std::is_constructible<V, Y>::value, - "regression on user-defined conversions in constructor"); - } - { using V = std::variant<AnyConstructible, NoConstructible>; static_assert( !std::is_constructible<V, std::in_place_type_t<NoConstructible>>::value, @@ -127,34 +99,6 @@ void test_T_ctor_basic() { static_assert(v.index() == 1, ""); static_assert(std::get<1>(v) == 42, ""); } - { - constexpr std::variant<unsigned, long> v(42); - static_assert(v.index() == 1, ""); - static_assert(std::get<1>(v) == 42, ""); - } - { - std::variant<std::string, bool const> v = "foo"; - assert(v.index() == 0); - assert(std::get<0>(v) == "foo"); - } - { - std::variant<bool volatile, std::unique_ptr<int>> v = nullptr; - assert(v.index() == 1); - assert(std::get<1>(v) == nullptr); - } - { - std::variant<bool volatile const, int> v = true; - assert(v.index() == 0); - assert(std::get<0>(v)); - } - { - std::variant<RValueConvertibleFrom<int>> v1 = 42; - assert(v1.index() == 0); - - int x = 42; - std::variant<RValueConvertibleFrom<int>, AnyConstructible> v2 = x; - assert(v2.index() == 1); - } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { using V = std::variant<const int &, int &&, long>; diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.fail.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.fail.cpp deleted file mode 100644 index 76b42ac226d..00000000000 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.fail.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// <variant> - -// template <class ...Types> class variant; - -// template <class T> constexpr variant(T&&) noexcept(see below); - -#include <variant> -#include <string> -#include <memory> - -int main(int, char**) -{ - std::variant<int, int> v1 = 1; // expected-error {{no viable conversion}} - std::variant<long, long long> v2 = 1; // expected-error {{no viable conversion}} - std::variant<char> v3 = 1; // expected-error {{no viable conversion}} - - std::variant<std::string, float> v4 = 1; // expected-error {{no viable conversion}} - std::variant<std::string, double> v5 = 1; // expected-error {{no viable conversion}} - std::variant<std::string, bool> v6 = 1; // expected-error {{no viable conversion}} - - std::variant<int, bool> v7 = "meow"; // expected-error {{no viable conversion}} - std::variant<int, bool const> v8 = "meow"; // expected-error {{no viable conversion}} - std::variant<int, bool volatile> v9 = "meow"; // expected-error {{no viable conversion}} - - std::variant<bool> v10 = std::true_type(); // expected-error {{no viable conversion}} - std::variant<bool> v11 = std::unique_ptr<char>(); // expected-error {{no viable conversion}} - std::variant<bool> v12 = nullptr; // expected-error {{no viable conversion}} -} |

