Re-apply "Disallow ArrayRef assignment from temporaries."

This re-applies r283798, disabled in r283803, with the static_assert
tests disabled under MSVC. The deleted functions still seem to catch
mistakes in MSVC, so it's not a significant loss.

Part of rdar://problem/16375365

llvm-svn: 283935
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp
index 43e5005..ca75800 100644
--- a/llvm/unittests/ADT/ArrayRefTest.cpp
+++ b/llvm/unittests/ADT/ArrayRefTest.cpp
@@ -31,6 +31,26 @@
     !std::is_convertible<ArrayRef<volatile int *>, ArrayRef<int *>>::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.)
+//
+// Disable this check under MSVC; even MSVC 2015 isn't inconsistent between
+// std::is_assignable and actually writing such an assignment.
+#if !defined(_MSC_VER)
+static_assert(
+    !std::is_assignable<ArrayRef<int *>, int *>::value,
+    "Assigning from single prvalue element");
+static_assert(
+    !std::is_assignable<ArrayRef<int *>, int * &&>::value,
+    "Assigning from single xvalue element");
+static_assert(
+    std::is_assignable<ArrayRef<int *>, int * &>::value,
+    "Assigning from single lvalue element");
+static_assert(
+    !std::is_assignable<ArrayRef<int *>, std::initializer_list<int *>>::value,
+    "Assigning from an initializer list");
+#endif
+
 namespace {
 
 TEST(ArrayRefTest, AllocatorCopy) {
@@ -161,6 +181,14 @@
   ArgTest12({1, 2});
 }
 
+TEST(ArrayRefTest, EmptyInitializerList) {
+  ArrayRef<int> 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};