Fix warnings in array and assoc containers

llvm-svn: 242629
diff --git a/libcxx/test/std/containers/associative/map/compare.pass.cpp b/libcxx/test/std/containers/associative/map/compare.pass.cpp
index aa4d599..26ac7af 100644
--- a/libcxx/test/std/containers/associative/map/compare.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/compare.pass.cpp
@@ -17,16 +17,36 @@
 // http://llvm.org/bugs/show_bug.cgi?id=16549
 
 #include <map>
+#include <utility>
+#include <cassert>
 
 struct Key {
   template <typename T> Key(const T&) {}
   bool operator< (const Key&) const { return false; }
 };
 
-int
-main()
+int main()
 {
-    std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
-    std::pair<std::map<Key, int>::iterator, bool> result =
-                        std::map<Key, int>().insert(std::make_pair(Key(0), 0));
+    typedef std::map<Key, int> MapT;
+    typedef MapT::iterator Iter;
+    typedef std::pair<Iter, bool> IterBool;
+    {
+        MapT m_empty;
+        MapT m_contains;
+        m_contains[Key(0)] = 42;
+
+        Iter it = m_empty.find(Key(0));
+        assert(it == m_empty.end());
+        it = m_contains.find(Key(0));
+        assert(it != m_contains.end());
+    }
+    {
+        MapT map;
+        IterBool result = map.insert(std::make_pair(Key(0), 42));
+        assert(result.second);
+        assert(result.first->second = 42);
+        IterBool result2 = map.insert(std::make_pair(Key(0), 43));
+        assert(!result2.second);
+        assert(map[Key(0)] == 42);
+    }
 }
diff --git a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
index d14603e..7e0fd41 100644
--- a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -16,14 +16,14 @@
 #include <map>
 #include <cassert>
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "min_allocator.h"
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
     {
-    typedef std::pair<MoveOnly, double> V;
     std::map<MoveOnly, double> m;
     assert(m.size() == 0);
     assert(m[1] == 0.0);
@@ -37,8 +37,6 @@
     assert(m[6] == 6.5);
     assert(m.size() == 2);
     }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if __cplusplus >= 201103L
     {
     typedef std::pair<MoveOnly, double> V;
     std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
diff --git a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
index b99d9bc..e6dc5aa 100644
--- a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
@@ -21,4 +21,5 @@
     typedef std::multimap<int, int> M2;
     M2::iterator i;
     M1::iterator j = i;
+    ((void)j);
 }
diff --git a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
index f5ee327..bc4328b 100644
--- a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
@@ -21,4 +21,5 @@
     typedef std::multiset<int> M2;
     M2::iterator i;
     M1::iterator j = i;
+    ((void)j);
 }
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
index b9775ee..34db59d 100644
--- a/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
index 08e4fd3..80b7d06 100644
--- a/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
index 8eb9762..1c9abdd 100644
--- a/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
index 675f495..f98dbbd 100644
--- a/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
index fe5a0d5..89b893a 100644
--- a/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
index 08e4377..82ce904 100644
--- a/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
index c7a4cb8..22bf657 100644
--- a/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
index 4f4fbcf..ae629bd 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
@@ -11,15 +11,22 @@
 
 // template <size_t I, class T, size_t N> T& get(array<T, N>& a);
 
+// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Warray-bounds"
+#endif
+
 #include <array>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
         typedef double T;
         typedef std::array<T, 3> C;
         C c = {1, 2, 3.5};
-        std::get<3>(c) = 5.5;    // Can't get element 3!
+        std::get<3>(c) = 5.5;  // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}}
     }
 }
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
index d9e242c..c455707 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
@@ -14,12 +14,17 @@
 #include <array>
 #include <cassert>
 
-#if __cplusplus > 201103L
+#include "test_macros.h"
+
+#include "../suppress_array_warnings.h"
+
+
+#if TEST_STD_VER > 11
 struct S {
    std::array<int, 3> a;
    int k;
    constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
-   };
+};
 
 constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
 #endif
@@ -35,7 +40,7 @@
         assert(c[1] == 5.5);
         assert(c[2] == 3.5);
     }
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
     {
         typedef double T;
         typedef std::array<T, 3> C;
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
index 1cbdfa4..ddc2ab2 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -14,6 +14,10 @@
 #include <array>
 #include <cassert>
 
+#include "test_macros.h"
+
+#include "../suppress_array_warnings.h"
+
 int main()
 {
     {
@@ -24,7 +28,7 @@
         assert(std::get<1>(c) == 2);
         assert(std::get<2>(c) == 3.5);
     }
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
     {
         typedef double T;
         typedef std::array<T, 3> C;
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
index 8eec3ce..412c7c7 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
@@ -11,14 +11,18 @@
 
 // template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
 
+// UNSUPPORTED: c++98, c++03
+
 #include <array>
 #include <memory>
 #include <utility>
 #include <cassert>
 
+#include "../suppress_array_warnings.h"
+
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
     {
         typedef std::unique_ptr<double> T;
         typedef std::array<T, 1> C;
@@ -26,5 +30,4 @@
         T t = std::get<0>(std::move(c));
         assert(*t == 3.5);
     }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/std/containers/sequences/array/at.pass.cpp b/libcxx/test/std/containers/sequences/array/at.pass.cpp
index b5cf8a5..c4f7acb 100644
--- a/libcxx/test/std/containers/sequences/array/at.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/at.pass.cpp
@@ -17,6 +17,10 @@
 #include <array>
 #include <cassert>
 
+#include "test_macros.h"
+
+#include "suppress_array_warnings.h"
+
 int main()
 {
     {
@@ -27,7 +31,7 @@
         assert(r1 == 1);
         r1 = 5.5;
         assert(c.front() == 5.5);
-        
+
         C::reference r2 = c.at(2);
         assert(r2 == 3.5);
         r2 = 7.5;
@@ -50,7 +54,7 @@
         catch (const std::out_of_range &) {}
     }
     
-#if _LIBCPP_STD_VER > 11 
+#if TEST_STD_VER > 11
     {
         typedef double T;
         typedef std::array<T, 3> C;
diff --git a/libcxx/test/std/containers/sequences/array/begin.pass.cpp b/libcxx/test/std/containers/sequences/array/begin.pass.cpp
index 9cba0d6..a6218ae 100644
--- a/libcxx/test/std/containers/sequences/array/begin.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/begin.pass.cpp
@@ -14,6 +14,8 @@
 #include <array>
 #include <cassert>
 
+#include "suppress_array_warnings.h"
+
 int main()
 {
     {
@@ -27,6 +29,4 @@
         *i = 5.5;
         assert(c[0] == 5.5);
     }
-    {
-    }
 }
diff --git a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
index 45a963b..ebe3a180 100644
--- a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
@@ -17,6 +17,10 @@
 #include <array>
 #include <cassert>
 
+#include "test_macros.h"
+
+#include "suppress_array_warnings.h"
+
 int main()
 {
     {
@@ -45,12 +49,12 @@
         assert(r2 == 3.5);
     }
 
-#if _LIBCPP_STD_VER > 11 
+#if TEST_STD_VER > 11
     {
         typedef double T;
         typedef std::array<T, 3> C;
         constexpr C c = {1, 2, 3.5};
-        
+
         constexpr T t1 = c.front();
         static_assert (t1 == 1, "");
 
diff --git a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
index e4dda0d..c550d14 100644
--- a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
@@ -17,6 +17,10 @@
 #include <array>
 #include <cassert>
 
+#include "test_macros.h"
+
+#include "suppress_array_warnings.h"
+
 int main()
 {
     {
@@ -42,13 +46,13 @@
         C::const_reference r2 = c[2];
         assert(r2 == 3.5);
     }
-    
-#if _LIBCPP_STD_VER > 11 
+
+#if TEST_STD_VER > 11
     {
         typedef double T;
         typedef std::array<T, 3> C;
         constexpr C c = {1, 2, 3.5};
-        
+
         constexpr T t1 = c[0];
         static_assert (t1 == 1, "");