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

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* ...@@ -6,3 +6,8 @@ build*
.settings .settings
cppcheck.log cppcheck.log
# gcov output files:
*.gcda
*.gcno
...@@ -46,14 +46,10 @@ if (UNIX) ...@@ -46,14 +46,10 @@ if (UNIX)
# Warnings # Warnings
################################################################################ ################################################################################
IF( NOT CMAKE_SYSTEM MATCHES "SunOS*") if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
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.*")
list(APPEND ADDITIONAL_CXX_FLAGS "-Weverything") list(APPEND ADDITIONAL_CXX_FLAGS "-Weverything")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-c++98-compat") 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-padded")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-old-style-cast") list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-old-style-cast")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-documentation-unknown-command") list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-documentation-unknown-command")
...@@ -63,6 +59,17 @@ if (UNIX) ...@@ -63,6 +59,17 @@ if (UNIX)
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-deprecated") list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-deprecated")
list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-weak-vtables") list(APPEND ADDITIONAL_CXX_FLAGS "-Wno-weak-vtables")
endif() 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 # STL Vector checks
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
static HandleT<EntityTag> static HandleT<EntityTag>
from_unsigned(size_t _idx) 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)); return HandleT<EntityTag>(static_cast<int>(_idx));
} else { } else {
assert(false); assert(false);
......
...@@ -238,7 +238,7 @@ inline void OpenVolumeMeshPropertyT<bool>::swap(size_t _i0, size_t _i1) ...@@ -238,7 +238,7 @@ inline void OpenVolumeMeshPropertyT<bool>::swap(size_t _i0, size_t _i1)
auto tmp = data_[_i0]; auto tmp = data_[_i0];
data_[_i0] = data_[_i1]; data_[_i0] = data_[_i1];
data_[_i1] = tmp;; data_[_i1] = tmp;
} }
template<> template<>
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
TopologyKernel& operator=(const TopologyKernel&) = default; TopologyKernel& operator=(const TopologyKernel&) = default;
void assign(const TopologyKernel *other) { void assign(const TopologyKernel *other) {
assert(other != nullptr);
*this = *other; *this = *other;
} }
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
static const unsigned char INVALID = 6; static const unsigned char INVALID = 6;
static inline unsigned char opposite_orientation(const unsigned char _d) { 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 // Constructor
......
#include <gtest/gtest.h> #include "unittests_common.hh"
#ifdef __clang__
# pragma GCC diagnostic ignored "-Weverything"
#endif
int main(int _argc, char** _argv) { int main(int _argc, char** _argv) {
......
#include <gtest/gtest.h> #include "unittests_common.hh"
#include <Unittests/unittests_common.hh>
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh> #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh> #include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
......
#ifndef INCLUDE_UNITTESTS_COMMON_HH #ifndef INCLUDE_UNITTESTS_COMMON_HH
#define INCLUDE_UNITTESTS_COMMON_HH #define INCLUDE_UNITTESTS_COMMON_HH
#include <gtest/gtest.h>
#include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh> #include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
#include <OpenVolumeMesh/Mesh/HexahedralMesh.hh> #include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
...@@ -9,11 +8,15 @@ ...@@ -9,11 +8,15 @@
#include <OpenVolumeMesh/Geometry/VectorT.hh> #include <OpenVolumeMesh/Geometry/VectorT.hh>
#ifdef __clang__ #ifdef __clang__
# pragma GCC diagnostic ignored "-Weverything"
# pragma GCC diagnostic ignored "-Wundef"
# pragma GCC diagnostic ignored "-Wglobal-constructors" # pragma GCC diagnostic ignored "-Wglobal-constructors"
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
# pragma GCC diagnostic ignored "-Wundef" # pragma GCC diagnostic ignored "-Wmissing-noreturn"
#endif #endif
#include <gtest/gtest.h>
#define EXPECT_HANDLE_EQ(a, b) EXPECT_EQ((a).idx(), (b).idx()) #define EXPECT_HANDLE_EQ(a, b) EXPECT_EQ((a).idx(), (b).idx())
#define EXPECT_HANDLE_NE(a, b) EXPECT_NE((a).idx(), (b).idx()) #define EXPECT_HANDLE_NE(a, b) EXPECT_NE((a).idx(), (b).idx())
......
#include <gtest/gtest.h> #include "unittests_common.hh"
#include <Unittests/unittests_common.hh>
#include <OpenVolumeMesh/FileManager/FileManager.hh> #include <OpenVolumeMesh/FileManager/FileManager.hh>
......
#include <gtest/gtest.h> #include "unittests_common.hh"
#include <Unittests/unittests_common.hh>
using namespace OpenVolumeMesh; using namespace OpenVolumeMesh;
......
#include <iostream> #include <iostream>
#include <gtest/gtest.h>
#include "unittests_common.hh" #include "unittests_common.hh"
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh> #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
......
#include <gtest/gtest.h> #include "unittests_common.hh"
#if __cplusplus >= 201103L || _MSC_VER >= 1800 #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