[libcxx] r242629 - Fix warnings in array and assoc containers
Eric Fiselier
eric at efcs.ca
Sat Jul 18 16:56:04 PDT 2015
Author: ericwf
Date: Sat Jul 18 18:56:04 2015
New Revision: 242629
URL: http://llvm.org/viewvc/llvm-project?rev=242629&view=rev
Log:
Fix warnings in array and assoc containers
Modified:
libcxx/trunk/include/__tree
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp
libcxx/trunk/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
libcxx/trunk/test/std/containers/associative/multimap/scary.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/scary.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.size/size.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp
libcxx/trunk/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
Modified: libcxx/trunk/include/__tree
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Sat Jul 18 18:56:04 2015
@@ -1118,8 +1118,8 @@ __tree<_Tp, _Compare, _Allocator>::__tre
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
- : __pair1_(__node_allocator(__a)),
- __begin_node_(__node_pointer()),
+ : __begin_node_(__node_pointer()),
+ __pair1_(__node_allocator(__a)),
__pair3_(0)
{
__begin_node() = __end_node();
@@ -1128,8 +1128,8 @@ __tree<_Tp, _Compare, _Allocator>::__tre
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
const allocator_type& __a)
- : __pair1_(__node_allocator(__a)),
- __begin_node_(__node_pointer()),
+ : __begin_node_(__node_pointer()),
+ __pair1_(__node_allocator(__a)),
__pair3_(0, __comp)
{
__begin_node() = __end_node();
Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sat Jul 18 18:56:04 2015
@@ -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')
Modified: libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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);
+ }
}
Modified: libcxx/trunk/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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;
Modified: libcxx/trunk/test/std/containers/associative/multimap/scary.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/scary.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/scary.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/scary.pass.cpp Sat Jul 18 18:56:04 2015
@@ -21,4 +21,5 @@ int main()
typedef std::multimap<int, int> M2;
M2::iterator i;
M1::iterator j = i;
+ ((void)j);
}
Modified: libcxx/trunk/test/std/containers/associative/multiset/scary.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/scary.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/scary.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multiset/scary.pass.cpp Sat Jul 18 18:56:04 2015
@@ -21,4 +21,5 @@ int main()
typedef std::multiset<int> M2;
M2::iterator i;
M1::iterator j = i;
+ ((void)j);
}
Modified: libcxx/trunk/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.size/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.size/size.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.size/size.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.size/size.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp Sat Jul 18 18:56:04 2015
@@ -14,6 +14,8 @@
#include <array>
#include <cassert>
+#include "../suppress_array_warnings.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp Sat Jul 18 18:56:04 2015
@@ -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 at array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}}
}
}
Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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;
Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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;
Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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;
Modified: libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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);
}
- {
- }
}
Modified: libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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, "");
Modified: libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp Sat Jul 18 18:56:04 2015
@@ -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, "");
Modified: libcxx/trunk/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp?rev=242629&r1=242628&r2=242629&view=diff
==============================================================================
--- libcxx/trunk/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp (original)
+++ libcxx/trunk/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp Sat Jul 18 18:56:04 2015
@@ -16,4 +16,5 @@
int main()
{
std::error_category* p = 0;
+ ((void)p);
}
More information about the cfe-commits
mailing list