diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-07-18 23:56:04 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-07-18 23:56:04 +0000 |
commit | 2decfad7c5df07030c27e70b98ca9feada760d3c (patch) | |
tree | df23e04f441d63a82cf185fce9334e6489560caf /libcxx/test | |
parent | 818139da5909af767e7579b819876e67149e9d9a (diff) | |
download | bcm5719-llvm-2decfad7c5df07030c27e70b98ca9feada760d3c.tar.gz bcm5719-llvm-2decfad7c5df07030c27e70b98ca9feada760d3c.zip |
Fix warnings in array and assoc containers
llvm-svn: 242629
Diffstat (limited to 'libcxx/test')
21 files changed, 92 insertions, 25 deletions
diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index cd5ee2807aa..2855ee50b4e 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -576,6 +576,7 @@ class Configuration(object): ] self.cxx.addCompileFlagIfSupported('-Wno-attributes') if self.cxx.type == 'clang' or self.cxx.type == 'apple-clang': + self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move') self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions') self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals') diff --git a/libcxx/test/std/containers/associative/map/compare.pass.cpp b/libcxx/test/std/containers/associative/map/compare.pass.cpp index aa4d5999ff4..26ac7af7d90 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 d14603e1a28..7e0fd41d56a 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 @@ int main() 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 b99d9bc2df9..e6dc5aaca95 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 @@ int main() 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 f5ee32714e8..bc4328b5332 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 @@ int main() 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 b9775eef067..34db59de5e2 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 08e4fd39d37..80b7d0636fe 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 8eb9762dcb8..1c9abdd0893 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 675f4950062..f98dbbda557 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 fe5a0d5c8db..89b893afd82 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 08e437739ee..82ce904db71 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 c7a4cb8df38..22bf6579914 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 4f4fbcf93af..ae629bd4daa 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 d9e242cd420..c4557078fc4 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 @@ int main() 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 1cbdfa4ff39..ddc2ab2855c 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 @@ int main() 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 8eec3ceff51..412c7c78aa8 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 @@ int main() 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 b5cf8a5aaa8..c4f7acb9f2a 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 @@ int main() 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 @@ int main() 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 9cba0d6fceb..a6218ae0b01 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 @@ int main() *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 45a963b9947..ebe3a180388 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 @@ int main() 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 e4dda0dc5cf..c550d141bcb 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 @@ int main() 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, ""); diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp index 23530587839..79162ddaa8f 100644 --- a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp @@ -16,4 +16,5 @@ int main() { std::error_category* p = 0; + ((void)p); } |