From 94071cc6e81ec908d7b427c72d6b6d1f89e4e133 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 26 Jan 2014 22:57:14 +0000 Subject: [PATCH] Clean up warnings. Fixes trac #9377. --- include/boost/unordered/detail/equivalent.hpp | 38 +++++++++---------- include/boost/unordered/detail/table.hpp | 24 ++++++------ include/boost/unordered/detail/unique.hpp | 14 +++---- test/helpers/invariants.hpp | 3 +- test/helpers/random_values.hpp | 4 +- test/unordered/Jamfile.v2 | 4 +- test/unordered/find_tests.cpp | 1 - test/unordered/insert_tests.cpp | 6 +-- test/unordered/noexcept_tests.cpp | 4 +- 9 files changed, 48 insertions(+), 50 deletions(-) diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index d569ad9f..ab175313 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -537,9 +537,9 @@ namespace boost { namespace unordered { namespace detail { node_pointer first_node = static_cast(prev->next_); link_pointer end = first_node->group_prev_->next_; - std::size_t count = this->delete_nodes(prev, end); + std::size_t deleted_count = this->delete_nodes(prev, end); this->fix_bucket(bucket_index, prev); - return count; + return deleted_count; } iterator erase(c_iterator r) @@ -558,21 +558,21 @@ namespace boost { namespace unordered { namespace detail { return iterator(r2.node_); } - link_pointer erase_nodes(node_pointer begin, node_pointer end) + link_pointer erase_nodes(node_pointer i, node_pointer j) { - std::size_t bucket_index = this->hash_to_bucket(begin->hash_); + std::size_t bucket_index = this->hash_to_bucket(i->hash_); - // Split the groups containing 'begin' and 'end'. - // And get the pointer to the node before begin while + // Split the groups containing 'i' and 'j'. + // And get the pointer to the node before i while // we're at it. - link_pointer prev = split_groups(begin, end); + link_pointer prev = split_groups(i, j); - // If we don't have a 'prev' it means that begin is at the + // If we don't have a 'prev' it means that i is at the // beginning of a block, so search through the blocks in the // same bucket. if (!prev) { prev = this->get_previous_start(bucket_index); - while (prev->next_ != begin) + while (prev->next_ != i) prev = static_cast(prev->next_)->group_prev_; } @@ -582,24 +582,24 @@ namespace boost { namespace unordered { namespace detail { static_cast(prev->next_)->group_prev_->next_; this->delete_nodes(prev, group_end); bucket_index = this->fix_bucket(bucket_index, prev); - } while(prev->next_ != end); + } while(prev->next_ != j); return prev; } - static link_pointer split_groups(node_pointer begin, node_pointer end) + static link_pointer split_groups(node_pointer i, node_pointer j) { - node_pointer prev = begin->group_prev_; - if (prev->next_ != begin) prev = node_pointer(); + node_pointer prev = i->group_prev_; + if (prev->next_ != i) prev = node_pointer(); - if (end) { - node_pointer first = end; - while (first != begin && first->group_prev_->next_ == first) { + if (j) { + node_pointer first = j; + while (first != i && first->group_prev_->next_ == first) { first = first->group_prev_; } - boost::swap(first->group_prev_, end->group_prev_); - if (first == begin) return prev; + boost::swap(first->group_prev_, j->group_prev_); + if (first == i) return prev; } if (prev) { @@ -607,7 +607,7 @@ namespace boost { namespace unordered { namespace detail { while (first->group_prev_->next_ == first) { first = first->group_prev_; } - boost::swap(first->group_prev_, begin->group_prev_); + boost::swap(first->group_prev_, i->group_prev_); } return prev; diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 4e92cb41..65fb780c 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -262,9 +262,9 @@ namespace boost { namespace unordered { namespace detail { return prev ? iterator(prev->next_) : iterator(); } - std::size_t hash_to_bucket(std::size_t hash) const + std::size_t hash_to_bucket(std::size_t hash_value) const { - return policy::to_bucket(bucket_count_, hash); + return policy::to_bucket(bucket_count_, hash_value); } float load_factor() const @@ -400,8 +400,8 @@ namespace boost { namespace unordered { namespace detail { { if (x.size_) { create_buckets(bucket_count_); - copy_nodes copy(node_alloc()); - table_impl::fill_buckets(x.begin(), *this, copy); + copy_nodes node_creator(node_alloc()); + table_impl::fill_buckets(x.begin(), *this, node_creator); } } @@ -414,9 +414,9 @@ namespace boost { namespace unordered { namespace detail { // TODO: Could pick new bucket size? create_buckets(bucket_count_); - move_nodes move(node_alloc()); + move_nodes node_creator(node_alloc()); node_holder nodes(x); - table_impl::fill_buckets(nodes.begin(), *this, move); + table_impl::fill_buckets(nodes.begin(), *this, node_creator); } } @@ -660,8 +660,8 @@ namespace boost { namespace unordered { namespace detail { // assign_nodes takes ownership of the container's elements, // assigning to them if possible, and deleting any that are // left over. - assign_nodes assign(*this); - table_impl::fill_buckets(x.begin(), *this, assign); + assign_nodes
node_creator(*this); + table_impl::fill_buckets(x.begin(), *this, node_creator); } void assign(table const& x, true_type) @@ -687,8 +687,8 @@ namespace boost { namespace unordered { namespace detail { // Finally copy the elements. if (x.size_) { create_buckets(bucket_count_); - copy_nodes copy(node_alloc()); - table_impl::fill_buckets(x.begin(), *this, copy); + copy_nodes node_creator(node_alloc()); + table_impl::fill_buckets(x.begin(), *this, node_creator); } } } @@ -735,9 +735,9 @@ namespace boost { namespace unordered { namespace detail { // move_assign_nodes takes ownership of the container's // elements, assigning to them if possible, and deleting // any that are left over. - move_assign_nodes
assign(*this); + move_assign_nodes
node_creator(*this); node_holder nodes(x); - table_impl::fill_buckets(nodes.begin(), *this, assign); + table_impl::fill_buckets(nodes.begin(), *this, node_creator); } } diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 59e6d5d3..88bbf0b6 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -530,9 +530,9 @@ namespace boost { namespace unordered { namespace detail { link_pointer end = static_cast(prev->next_)->next_; - std::size_t count = this->delete_nodes(prev, end); + std::size_t deleted_count = this->delete_nodes(prev, end); this->fix_bucket(bucket_index, prev); - return count; + return deleted_count; } iterator erase(c_iterator r) @@ -551,19 +551,19 @@ namespace boost { namespace unordered { namespace detail { return iterator(r2.node_); } - void erase_nodes(node_pointer begin, node_pointer end) + void erase_nodes(node_pointer i, node_pointer j) { - std::size_t bucket_index = this->hash_to_bucket(begin->hash_); + std::size_t bucket_index = this->hash_to_bucket(i->hash_); - // Find the node before begin. + // Find the node before i. link_pointer prev = this->get_previous_start(bucket_index); - while(prev->next_ != begin) prev = prev->next_; + while(prev->next_ != i) prev = prev->next_; // Delete the nodes. do { this->delete_node(prev); bucket_index = this->fix_bucket(bucket_index, prev); - } while (prev->next_ != end); + } while (prev->next_ != j); } //////////////////////////////////////////////////////////////////////// diff --git a/test/helpers/invariants.hpp b/test/helpers/invariants.hpp index fec7ee65..e18ef865 100644 --- a/test/helpers/invariants.hpp +++ b/test/helpers/invariants.hpp @@ -105,7 +105,8 @@ namespace test i = 0; i < x1.bucket_count(); ++i) { for (BOOST_DEDUCED_TYPENAME X::const_local_iterator - begin = x1.begin(i), end = x1.end(i); begin != end; ++begin) + begin2 = x1.begin(i), end2 = x1.end(i); + begin2 != end2; ++begin2) { ++bucket_size; } diff --git a/test/helpers/random_values.hpp b/test/helpers/random_values.hpp index 46eeb392..f8ba252c 100644 --- a/test/helpers/random_values.hpp +++ b/test/helpers/random_values.hpp @@ -41,7 +41,7 @@ namespace test int count = type_ == generate_collisions ? 1 + (generate(int_ptr) % 5) : 1; - for(int i = 0; i < count; ++i) { + for(int j = 0; j < count; ++j) { x.push_back(value); } } @@ -71,7 +71,7 @@ namespace test int count = type_ == generate_collisions ? 1 + (generate(int_ptr) % 5) : 1; - for(int i = 0; i < count; ++i) { + for(int j = 0; j < count; ++j) { x.push_back(std::pair( key, generate(mapped_ptr))); } diff --git a/test/unordered/Jamfile.v2 b/test/unordered/Jamfile.v2 index 53e0d157..52e09bf0 100644 --- a/test/unordered/Jamfile.v2 +++ b/test/unordered/Jamfile.v2 @@ -11,8 +11,8 @@ project unordered-test/unordered intel:on # Would be nice to define -Wundef, but I'm getting warnings from # Boost.Preprocessor on trunk. - gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wno-long-long -Wfloat-equal" - darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal" + gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wno-long-long -Wfloat-equal -Wshadow" + darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" #gcc:_GLIBCXX_DEBUG #darwin:_GLIBCXX_DEBUG ; diff --git a/test/unordered/find_tests.cpp b/test/unordered/find_tests.cpp index c3d58828..a310d40c 100644 --- a/test/unordered/find_tests.cpp +++ b/test/unordered/find_tests.cpp @@ -117,7 +117,6 @@ struct compatible_predicate template void find_compatible_keys_test(X*, test::random_generator generator) { - typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; typedef BOOST_DEDUCED_TYPENAME test::random_values::iterator value_iterator; test::random_values v(500, generator); diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index fb66e2e4..e80a8c1c 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -363,8 +363,6 @@ void equivalent_emplace_tests1(X*, test::random_generator generator) template void move_emplace_tests(X*, test::random_generator generator) { - typedef test::ordered ordered; - std::cerr<<"emplace(move(value)) tests for containers with unique keys.\n"; X x; @@ -666,8 +664,8 @@ UNORDERED_AUTO_TEST(insert_initializer_list_multimap) struct overloaded_constructor { - overloaded_constructor(int x1 = 1, int x2 = 2, int x3 = 3, int x4 = 4) - : x1(x1), x2(x2), x3(x3), x4(x4) {} + overloaded_constructor(int x1_ = 1, int x2_ = 2, int x3_ = 3, int x4_ = 4) + : x1(x1_), x2(x2_), x3(x3_), x4(x4_) {} int x1, x2, x3, x4; diff --git a/test/unordered/noexcept_tests.cpp b/test/unordered/noexcept_tests.cpp index a4ddfa43..0f066f87 100644 --- a/test/unordered/noexcept_tests.cpp +++ b/test/unordered/noexcept_tests.cpp @@ -69,7 +69,7 @@ namespace noexcept_tests BOOST_NOEXCEPT {} hash_nothrow_move() { test_throw("Constructor"); } - hash_nothrow_move(hash_nothrow_move const& x) { test_throw("Copy"); } + hash_nothrow_move(hash_nothrow_move const&) { test_throw("Copy"); } hash_nothrow_move& operator=(hash_nothrow_move const&) { test_throw("Assign"); return *this; } std::size_t operator()(int x) const @@ -85,7 +85,7 @@ namespace noexcept_tests equal_to_nothrow_move(BOOST_RV_REF(equal_to_nothrow_move)) BOOST_NOEXCEPT {} equal_to_nothrow_move() { test_throw("Constructor"); } - equal_to_nothrow_move(equal_to_nothrow_move const& x) + equal_to_nothrow_move(equal_to_nothrow_move const&) { test_throw("Copy"); } equal_to_nothrow_move& operator=(equal_to_nothrow_move const&) { test_throw("Assign"); return *this; }