Cleanup additional GCC warnings
When turning on the following flags, several additional warnings were generated, which have been cleaned up in this patch. The flags included: -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wctor-dtor-privacy -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Woverloaded-virtual
This commit is contained in:
1 parent
38f453d608
commit
d641796b21
10 files changed
+21
-20
No files matched your search
@@ -24,9 +24,9 @@ else()
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
if(COMPILER_SUPPORTS_CXX14)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++14 -O3 -Wall -Wno-missing-braces")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++14 -O3 -Wall -Wextra -Wpedantic -Wno-missing-braces -Wconversion -Wsign-conversion -Wctor-dtor-privacy -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Woverloaded-virtual")
|
||||
elseif(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++11 -O3 -Wall -Wno-missing-braces")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++11 -O3 -Wall -Wextra -Wpedantic -Wno-missing-braces -Wconversion -Wsign-conversion -Wctor-dtor-privacy -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Woverloaded-virtual")
|
||||
else()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace gsl;;
|
||||
using namespace gsl;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -37,7 +37,7 @@ SUITE(bounds_test)
|
||||
j++)
|
||||
{
|
||||
use(j);
|
||||
use(point[j]);
|
||||
use(point[static_cast<size_t>(j)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1427,14 +1427,14 @@ SUITE(multi_span_tests)
|
||||
}
|
||||
}
|
||||
|
||||
size_t check_sum = 0;
|
||||
auto check_sum = 0;
|
||||
for (auto i = 0; i < length; ++i) {
|
||||
check_sum += av[i][1];
|
||||
}
|
||||
|
||||
{
|
||||
auto idx = 0;
|
||||
size_t sum = 0;
|
||||
auto sum = 0;
|
||||
for (auto num : section) {
|
||||
CHECK(num == av[idx][1]);
|
||||
sum += num;
|
||||
@@ -1444,8 +1444,8 @@ SUITE(multi_span_tests)
|
||||
CHECK(sum == check_sum);
|
||||
}
|
||||
{
|
||||
size_t idx = length - 1;
|
||||
size_t sum = 0;
|
||||
auto idx = length - 1;
|
||||
auto sum = 0;
|
||||
for (auto iter = section.rbegin(); iter != section.rend(); ++iter) {
|
||||
CHECK(*iter == av[idx][1]);
|
||||
sum += *iter;
|
||||
@@ -1650,7 +1650,7 @@ SUITE(multi_span_tests)
|
||||
{
|
||||
multi_span<int, dynamic_range> av = a;
|
||||
auto wav = as_writeable_bytes(av);
|
||||
CHECK(wav.data() == (byte*) &a[0]);
|
||||
CHECK(wav.data() == reinterpret_cast<byte*>(&a[0]));
|
||||
CHECK(wav.length() == sizeof(a));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ SUITE(NotNullTests)
|
||||
not_null<Unrelated*> s = reinterpret_cast<Unrelated*>(p);
|
||||
#endif
|
||||
not_null<Unrelated*> t = reinterpret_cast<Unrelated*>(p.get());
|
||||
CHECK((void*)p.get() == (void*)t.get());
|
||||
CHECK(reinterpret_cast<void*>(p.get()) == reinterpret_cast<void*>(t.get()));
|
||||
}
|
||||
|
||||
TEST(TestNotNullAssignment)
|
||||
|
||||
@@ -1336,8 +1336,8 @@ SUITE(span_tests)
|
||||
#endif
|
||||
{
|
||||
auto f = [&]() {
|
||||
span<int, 4> s4 = {arr2, 2};
|
||||
static_cast<void>(s4);
|
||||
span<int, 4> _s4 = {arr2, 2};
|
||||
static_cast<void>(_s4);
|
||||
};
|
||||
CHECK_THROW(f(), fail_fast);
|
||||
}
|
||||
@@ -1345,8 +1345,8 @@ SUITE(span_tests)
|
||||
// this should fail - we are trying to assign a small dynamic span to a fixed_size larger one
|
||||
span<int> av = arr2;
|
||||
auto f = [&]() {
|
||||
span<int, 4> s4 = av;
|
||||
static_cast<void>(s4);
|
||||
span<int, 4> _s4 = av;
|
||||
static_cast<void>(_s4);
|
||||
};
|
||||
CHECK_THROW(f(), fail_fast);
|
||||
}
|
||||
|
||||
@@ -701,7 +701,7 @@ SUITE(strided_span_tests)
|
||||
|
||||
int s = sizeof(int) / sizeof(byte);
|
||||
auto d2 = 3 * s;
|
||||
auto d1 = sizeof(int) * 12 / d2;
|
||||
auto d1 = narrow_cast<int>(sizeof(int)) * 12 / d2;
|
||||
|
||||
// convert to 4x12 array of bytes
|
||||
auto av = as_multi_span(as_bytes(as_multi_span(arr, 4)), dim(d1), dim(d2));
|
||||
|
||||
@@ -67,7 +67,7 @@ SUITE(utils_tests)
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
void g() { j += 1; };
|
||||
void g() { j += 1; }
|
||||
TEST(finally_function_ptr)
|
||||
{
|
||||
j = 0;
|
||||
|
||||
Reference in new issue
Block a user