From: Zachary Turner Date: Mon, 10 Oct 2016 21:36:23 +0000 (+0000) Subject: Revert "Disallow ArrayRef assignment from temporaries." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b260e3ad992e144e5ea3df9d6d9e5e53b7f58707;p=llvm Revert "Disallow ArrayRef assignment from temporaries." This reverts commit r283798, as it causes static asserts on MSVC 2015 with the following errors: ArrayRefTest.cpp(38): error C2338: Assigning from single prvalue element ArrayRefTest.cpp(41): error C2338: Assigning from single xvalue element ArrayRefTest.cpp(47): error C2338: Assigning from an initializer list git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283803 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 3efc09ddd36..c1d66c69903 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -219,22 +219,6 @@ namespace llvm { return Data[Index]; } - /// Disallow accidental assignment from a temporary. - /// - /// The declaration here is extra complicated so that "arrayRef = {}" - /// continues to select the move assignment operator. - template - typename std::enable_if::value, ArrayRef>::type & - operator=(U &&Temporary) = delete; - - /// Disallow accidental assignment from a temporary. - /// - /// The declaration here is extra complicated so that "arrayRef = {}" - /// continues to select the move assignment operator. - template - typename std::enable_if::value, ArrayRef>::type & - operator=(std::initializer_list) = delete; - /// @} /// @name Expensive Operations /// @{ diff --git a/unittests/ADT/ArrayRefTest.cpp b/unittests/ADT/ArrayRefTest.cpp index f046da8a833..43e5005e62d 100644 --- a/unittests/ADT/ArrayRefTest.cpp +++ b/unittests/ADT/ArrayRefTest.cpp @@ -31,21 +31,6 @@ static_assert( !std::is_convertible, ArrayRef>::value, "Removing volatile"); -// Check that we can't accidentally assign a temporary location to an ArrayRef. -// (Unfortunately we can't make use of the same thing with constructors.) -static_assert( - !std::is_assignable, int *>::value, - "Assigning from single prvalue element"); -static_assert( - !std::is_assignable, int * &&>::value, - "Assigning from single xvalue element"); -static_assert( - std::is_assignable, int * &>::value, - "Assigning from single lvalue element"); -static_assert( - !std::is_assignable, std::initializer_list>::value, - "Assigning from an initializer list"); - namespace { TEST(ArrayRefTest, AllocatorCopy) { @@ -176,14 +161,6 @@ TEST(ArrayRefTest, InitializerList) { ArgTest12({1, 2}); } -TEST(ArrayRefTest, EmptyInitializerList) { - ArrayRef A = {}; - EXPECT_TRUE(A.empty()); - - A = {}; - EXPECT_TRUE(A.empty()); -} - // Test that makeArrayRef works on ArrayRef (no-op) TEST(ArrayRefTest, makeArrayRef) { static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8};