Commit 3cf0d296 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'warnings' into 'master'

More work on compiler warnings

See merge request !64
parents c373d3ef 6f29b77c
Pipeline #10646 passed with stage
in 9 minutes and 58 seconds
......@@ -6,3 +6,8 @@ build*
.settings
cppcheck.log
# gcov output files:
*.gcda
*.gcno
......@@ -46,14 +46,10 @@ if (UNIX)
# Warnings
################################################################################
IF( NOT CMAKE_SYSTEM MATCHES "SunOS*")
list(APPEND ADDITIONAL_CXX_FLAGS "-W" "-Wall" "-Wno-unused" )
list(APPEND ADDITIONAL_C_FLAGS "-W" "-Wall" "-Wno-unused" )
ENDIF()
if ("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
list(APPEND ADDITIONAL_CXX_FLAGS "-Weverything")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-c++98-compat")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-c++98-compat-pedantic")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-padded")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-old-style-cast")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-documentation-unknown-command")
......@@ -63,6 +59,17 @@ if (UNIX)
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-deprecated")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-weak-vtables")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wall")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wextra")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wpedantic")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wshadow")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wpointer-arith")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wcast-qual")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wconversion")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wtype-limits")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wsign-compare")
endif()
################################################################################
# STL Vector checks
......
......@@ -112,7 +112,7 @@ public:
static HandleT<EntityTag>
from_unsigned(size_t _idx)
{
if (_idx <= std::numeric_limits<int>::max()) {
if (_idx <= static_cast<size_t>(std::numeric_limits<int>::max())) {
return HandleT<EntityTag>(static_cast<int>(_idx));
} else {
assert(false);
......
......@@ -238,7 +238,7 @@ inline void OpenVolumeMeshPropertyT<bool>::swap(size_t _i0, size_t _i1)
auto tmp = data_[_i0];
data_[_i0] = data_[_i1];
data_[_i1] = tmp;;
data_[_i1] = tmp;
}
template<>
......
......@@ -55,6 +55,7 @@ public:
TopologyKernel& operator=(const TopologyKernel&) = default;
void assign(const TopologyKernel *other) {
assert(other != nullptr);
*this = *other;
}
......
......@@ -88,7 +88,7 @@ public:
static const unsigned char INVALID = 6;
static inline unsigned char opposite_orientation(const unsigned char _d) {
return (_d % 2 == 0 ? _d + 1 : _d - 1);
return static_cast<unsigned char>(_d % 2 == 0 ? _d + 1 : _d - 1);
}
// Constructor
......
#include <gtest/gtest.h>
#ifdef __clang__
# pragma GCC diagnostic ignored "-Weverything"
#endif
#include "unittests_common.hh"
int main(int _argc, char** _argv) {
......
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include "unittests_common.hh"
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
......
#ifndef INCLUDE_UNITTESTS_COMMON_HH
#define INCLUDE_UNITTESTS_COMMON_HH
#include <gtest/gtest.h>
#include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
#include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
......@@ -9,11 +8,15 @@
#include <OpenVolumeMesh/Geometry/VectorT.hh>
#ifdef __clang__
# pragma GCC diagnostic ignored "-Weverything"
# pragma GCC diagnostic ignored "-Wundef"
# pragma GCC diagnostic ignored "-Wglobal-constructors"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
# pragma GCC diagnostic ignored "-Wundef"
# pragma GCC diagnostic ignored "-Wmissing-noreturn"
#endif
#include <gtest/gtest.h>
#define EXPECT_HANDLE_EQ(a, b) EXPECT_EQ((a).idx(), (b).idx())
#define EXPECT_HANDLE_NE(a, b) EXPECT_NE((a).idx(), (b).idx())
......
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include "unittests_common.hh"
#include <OpenVolumeMesh/FileManager/FileManager.hh>
......
#include <gtest/gtest.h>
#include "unittests_common.hh"
#include <Unittests/unittests_common.hh>
using namespace OpenVolumeMesh;
......
#include <iostream>
#include <gtest/gtest.h>
#include "unittests_common.hh"
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
......
#include <gtest/gtest.h>
#include "unittests_common.hh"
#if __cplusplus >= 201103L || _MSC_VER >= 1800
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment