1
0
forked from boostorg/move

Support Clang's -Wconversion -Wfloat-conversion -Wsign-conversion with -Werror

This commit is contained in:
Ion Gaztañaga
2021-10-20 00:16:34 +02:00
parent 82dfdf8e78
commit 55bbf331b0
14 changed files with 57 additions and 60 deletions

View File

@ -13,14 +13,13 @@
#define BOOST_MOVE_ADAPTIVE_MERGE_HPP #define BOOST_MOVE_ADAPTIVE_MERGE_HPP
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#include <boost/move/algo/detail/adaptive_sort_merge.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wsign-conversion"
#endif #endif
#include <boost/move/algo/detail/adaptive_sort_merge.hpp>
namespace boost { namespace boost {
namespace movelib { namespace movelib {
@ -355,7 +354,7 @@ void adaptive_merge( RandIt first, RandIt middle, RandIt last, Compare comp
} //namespace movelib { } //namespace movelib {
} //namespace boost { } //namespace boost {
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -14,14 +14,14 @@
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #include <boost/move/algo/detail/adaptive_sort_merge.hpp>
#include <boost/core/ignore_unused.hpp>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wsign-conversion"
#endif #endif
#include <boost/move/algo/detail/adaptive_sort_merge.hpp>
#include <boost/core/ignore_unused.hpp>
namespace boost { namespace boost {
namespace movelib { namespace movelib {
@ -647,7 +647,7 @@ void adaptive_sort( RandIt first, RandIt last, Compare comp)
#include <boost/move/detail/config_end.hpp> #include <boost/move/detail/config_end.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -44,11 +44,6 @@
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/detail/reverse_iterator.hpp> #include <boost/move/detail/reverse_iterator.hpp>
#include <boost/move/algo/move.hpp> #include <boost/move/algo/move.hpp>
#include <boost/move/algo/detail/merge.hpp> #include <boost/move/algo/detail/merge.hpp>
@ -63,6 +58,11 @@
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#include <limits.h> #include <limits.h>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#ifndef BOOST_MOVE_ADAPTIVE_SORT_STATS_LEVEL #ifndef BOOST_MOVE_ADAPTIVE_SORT_STATS_LEVEL
#define BOOST_MOVE_ADAPTIVE_SORT_STATS_LEVEL 1 #define BOOST_MOVE_ADAPTIVE_SORT_STATS_LEVEL 1
#endif #endif
@ -1527,7 +1527,7 @@ typename iterator_traits<RandIt>::size_type
} //namespace movelib { } //namespace movelib {
} //namespace boost { } //namespace boost {
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -24,16 +24,16 @@
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/detail/workaround.hpp> #include <boost/move/detail/workaround.hpp>
#include <boost/move/detail/iterator_traits.hpp> #include <boost/move/detail/iterator_traits.hpp>
#include <boost/move/algo/detail/is_sorted.hpp> #include <boost/move/algo/detail/is_sorted.hpp>
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost { namespace movelib{ namespace boost { namespace movelib{
template <class RandomAccessIterator, class Compare> template <class RandomAccessIterator, class Compare>
@ -112,7 +112,7 @@ BOOST_MOVE_FORCEINLINE void heap_sort(RandomAccessIterator first, RandomAccessIt
}} //namespace boost { namespace movelib{ }} //namespace boost { namespace movelib{
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -22,11 +22,6 @@
# pragma once # pragma once
#endif #endif
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/algo/move.hpp> #include <boost/move/algo/move.hpp>
#include <boost/move/detail/iterator_traits.hpp> #include <boost/move/detail/iterator_traits.hpp>
@ -38,6 +33,11 @@
#include <boost/move/detail/placement_new.hpp> #include <boost/move/detail/placement_new.hpp>
#include <boost/move/detail/iterator_to_raw_pointer.hpp> #include <boost/move/detail/iterator_to_raw_pointer.hpp>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost { namespace movelib{ namespace boost { namespace movelib{
// @cond // @cond
@ -130,7 +130,7 @@ void insertion_sort_uninitialized_copy
}} //namespace boost { namespace movelib{ }} //namespace boost { namespace movelib{
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -11,11 +11,6 @@
#ifndef BOOST_MOVE_MERGE_HPP #ifndef BOOST_MOVE_MERGE_HPP
#define BOOST_MOVE_MERGE_HPP #define BOOST_MOVE_MERGE_HPP
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/core/ignore_unused.hpp> #include <boost/core/ignore_unused.hpp>
#include <boost/move/algo/move.hpp> #include <boost/move/algo/move.hpp>
#include <boost/move/adl_move_swap.hpp> #include <boost/move/adl_move_swap.hpp>
@ -27,6 +22,11 @@
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <cstddef> #include <cstddef>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost { namespace boost {
namespace movelib { namespace movelib {
@ -941,7 +941,7 @@ void merge_adaptive_ONlogN(BidirectionalIterator first,
} //namespace movelib { } //namespace movelib {
} //namespace boost { } //namespace boost {
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -23,13 +23,6 @@
#endif #endif
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/detail/workaround.hpp> #include <boost/move/detail/workaround.hpp>
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
@ -41,6 +34,11 @@
#include <boost/move/algo/detail/insertion_sort.hpp> #include <boost/move/algo/detail/insertion_sort.hpp>
#include <cassert> #include <cassert>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost { namespace boost {
namespace movelib { namespace movelib {
@ -209,7 +207,7 @@ void stable_sort_adaptive_ONlogN2(BidirectionalIterator first,
}} //namespace boost { namespace movelib{ }} //namespace boost { namespace movelib{
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -48,11 +48,6 @@
#include <boost/move/detail/config_begin.hpp> #include <boost/move/detail/config_begin.hpp>
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/detail/workaround.hpp> #include <boost/move/detail/workaround.hpp>
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
#include <boost/move/algo/detail/insertion_sort.hpp> #include <boost/move/algo/detail/insertion_sort.hpp>
@ -62,6 +57,11 @@
#include <boost/move/adl_move_swap.hpp> #include <boost/move/adl_move_swap.hpp>
#include <cstddef> #include <cstddef>
#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost { namespace boost {
namespace movelib { namespace movelib {
@ -335,7 +335,7 @@ void pdqsort(Iter begin, Iter end, Compare comp)
} //namespace movelib { } //namespace movelib {
} //namespace boost { } //namespace boost {
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -11,17 +11,16 @@
#ifndef BOOST_MOVE_SET_DIFFERENCE_HPP #ifndef BOOST_MOVE_SET_DIFFERENCE_HPP
#define BOOST_MOVE_SET_DIFFERENCE_HPP #define BOOST_MOVE_SET_DIFFERENCE_HPP
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/move/algo/move.hpp> #include <boost/move/algo/move.hpp>
#include <boost/move/iterator.hpp> #include <boost/move/iterator.hpp>
#include <boost/move/utility_core.hpp> #include <boost/move/utility_core.hpp>
namespace boost { #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
namespace boost {
namespace move_detail{ namespace move_detail{
template<class InputIt, class OutputIt> template<class InputIt, class OutputIt>
@ -204,7 +203,7 @@ ForwardOutputIt1 inplace_set_unique_difference
return first1; return first1;
} }
#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) #if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@ -121,9 +121,9 @@ inline boost::uint64_t nsec_clock() BOOST_NOEXCEPT
{ {
struct timespec count; struct timespec count;
::clock_gettime(BOOST_MOVE_DETAIL_CLOCK_MONOTONIC, &count); ::clock_gettime(BOOST_MOVE_DETAIL_CLOCK_MONOTONIC, &count);
boost::uint64_t r = count.tv_sec; boost::uint64_t r = static_cast<boost::uint64_t>(count.tv_sec);
r *= 1000000000U; r *= 1000000000U;
r += count.tv_nsec; r += static_cast<boost::uint64_t>(count.tv_nsec);
return r; return r;
} }

View File

@ -174,7 +174,7 @@ bool measure_algo(T *elements, std::size_t element_count, std::size_t split_pos,
nanosecond_type new_clock = timer.elapsed().wall; nanosecond_type new_clock = timer.elapsed().wall;
//std::cout << "Cmp:" << order_perf_type::num_compare << " Cpy:" << order_perf_type::num_copy; //for old compilers without ll size argument //std::cout << "Cmp:" << order_perf_type::num_compare << " Cpy:" << order_perf_type::num_copy; //for old compilers without ll size argument
std::printf("Cmp:%8.04f Cpy:%9.04f", double(order_perf_type::num_compare)/element_count, double(order_perf_type::num_copy)/element_count ); std::printf("Cmp:%8.04f Cpy:%9.04f", double(order_perf_type::num_compare)/double(element_count), double(order_perf_type::num_copy)/double(element_count) );
double time = double(new_clock); double time = double(new_clock);

View File

@ -206,7 +206,7 @@ bool measure_algo(T *elements, std::size_t element_count, std::size_t alg, nanos
nanosecond_type new_clock = timer.elapsed().wall; nanosecond_type new_clock = timer.elapsed().wall;
//std::cout << "Cmp:" << order_perf_type::num_compare << " Cpy:" << order_perf_type::num_copy; //for old compilers without ll size argument //std::cout << "Cmp:" << order_perf_type::num_compare << " Cpy:" << order_perf_type::num_copy; //for old compilers without ll size argument
std::printf("Cmp:%7.03f Cpy:%8.03f", double(order_perf_type::num_compare)/element_count, double(order_perf_type::num_copy)/element_count ); std::printf("Cmp:%7.03f Cpy:%8.03f", double(order_perf_type::num_compare)/double(element_count), double(order_perf_type::num_copy)/double(element_count) );
double time = double(new_clock); double time = double(new_clock);

View File

@ -15,6 +15,7 @@
#include <boost/move/core.hpp> #include <boost/move/core.hpp>
#include <boost/move/detail/unique_ptr_meta_utils.hpp> #include <boost/move/detail/unique_ptr_meta_utils.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <cstddef>
////////////////////////////////////////////// //////////////////////////////////////////////
// //
@ -188,7 +189,7 @@ BOOST_STATIC_ASSERT((::boost::move_upmu::is_convertible<B, A>::value));
struct I; struct I;
void check(int i); void check(int i);
I* get(); I* get();
I* get_array(int i); I* get_array(std::size_t i);
#include <boost/move/unique_ptr.hpp> #include <boost/move/unique_ptr.hpp>

View File

@ -30,7 +30,7 @@ struct I
int I::count = 0; int I::count = 0;
I* get() {return new I;} I* get() {return new I;}
I* get_array(int i) {return new I[i];} I* get_array(std::size_t i) {return new I[i];}
void check(int i) void check(int i)
{ {