build: enable -Wimplicit-fallthrough warning for OpenCV modules

pull/11352/head
Alexander Alekhin 7 years ago
parent 647eb243ae
commit 12e8e33144
  1. 2
      3rdparty/ittnotify/CMakeLists.txt
  2. 1
      3rdparty/libjasper/CMakeLists.txt
  3. 2
      3rdparty/libjpeg/CMakeLists.txt
  4. 2
      3rdparty/libpng/CMakeLists.txt
  5. 1
      3rdparty/libtiff/CMakeLists.txt
  6. 1
      3rdparty/libwebp/CMakeLists.txt
  7. 1
      3rdparty/openexr/CMakeLists.txt
  8. 1
      3rdparty/protobuf/CMakeLists.txt
  9. 1
      3rdparty/zlib/CMakeLists.txt
  10. 5
      cmake/OpenCVCompilerOptions.cmake
  11. 2
      cmake/OpenCVUtils.cmake
  12. 5
      modules/core/src/persistence.cpp
  13. 2
      modules/core/src/persistence.hpp
  14. 2
      modules/core/src/persistence_base64.cpp
  15. 2
      modules/core/src/softfloat.cpp
  16. 1
      modules/imgproc/test/ocl/test_color.cpp
  17. 7
      modules/videoio/src/cap.cpp

@ -15,6 +15,8 @@ if(NOT WIN32)
endif()
endif()
ocv_warnings_disable(CMAKE_C_FLAGS -Wimplicit-fallthrough)
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
set(ITT_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include")

@ -27,6 +27,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-unini
-Wno-unused-but-set-parameter -Wmissing-declarations -Wunused -Wshadow
-Wsign-compare -Wstrict-overflow -Wpointer-compare
-Wabsolute-value # clang on Linux
-Wimplicit-fallthrough
)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wstrict-prototypes) # clang
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005

@ -32,7 +32,7 @@ if(CV_GCC OR CV_CLANG)
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
endif()
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align -Wshadow -Wunused -Wshift-negative-value)
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align -Wshadow -Wunused -Wshift-negative-value -Wimplicit-fallthrough)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4244 /wd4267) # vs2005

@ -63,7 +63,7 @@ endif(MSVC)
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align)
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align -Wimplicit-fallthrough)
set_target_properties(${PNG_LIBRARY}
PROPERTIES OUTPUT_NAME ${PNG_LIBRARY}

@ -438,6 +438,7 @@ endif()
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
-Wmisleading-indentation
-Wimplicit-fallthrough
)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter

@ -37,6 +37,7 @@ endif()
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wunused-function -Wshadow -Wmaybe-uninitialized
-Wmissing-prototypes # clang
-Wmissing-declarations # gcc
-Wimplicit-fallthrough
)
ocv_warnings_disable(CMAKE_C_FLAGS /wd4244 /wd4267) # vs2005

@ -45,6 +45,7 @@ source_group("Src" FILES ${lib_srcs})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra
-Wdeprecated-declarations -Wmisleading-indentation -Wdeprecated
-Wsuggest-override -Winconsistent-missing-override
-Wimplicit-fallthrough
)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64

@ -21,6 +21,7 @@ else()
-Wunused-function -Wunused-const-variable -Wshorten-64-to-32 -Wno-invalid-offsetof
-Wenum-compare-switch
-Wsuggest-override -Winconsistent-missing-override
-Wimplicit-fallthrough
)
endif()
if(CV_ICC)

@ -82,6 +82,7 @@ set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshift-negative-value
-Wundef # _LFS64_LARGEFILE is not defined
/wd4267 # MSVS 2015 (x64) + zlib 1.2.11
-Wimplicit-fallthrough
)
set_target_properties(${ZLIB_LIBRARY} PROPERTIES

@ -119,7 +119,10 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-Wno-delete-non-virtual-dtor)
add_extra_compiler_option(-Wno-unnamed-type-template-args)
add_extra_compiler_option(-Wno-comment)
add_extra_compiler_option(-Wno-implicit-fallthrough)
if(NOT OPENCV_SKIP_IMPLICIT_FALLTHROUGH
AND NOT " ${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}" MATCHES "implicit-fallthrough")
add_extra_compiler_option(-Wimplicit-fallthrough=3)
endif()
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.2.0)
add_extra_compiler_option(-Wno-strict-overflow) # Issue is fixed in GCC 7.2.1
endif()

@ -504,7 +504,7 @@ macro(ocv_warnings_disable)
foreach(var ${_flag_vars})
foreach(warning ${_gxx_warnings})
if(NOT warning MATCHES "^-Wno-")
string(REPLACE "${warning}" "" ${var} "${${var}}")
string(REGEX REPLACE "${warning}(=[^ ]*)?" "" ${var} "${${var}}")
string(REPLACE "-W" "-Wno-" warning "${warning}")
endif()
ocv_check_flag_support(${var} "${warning}" _varname "")

@ -148,9 +148,8 @@ CvGenericHash* cvCreateMap( int flags, int header_size, int elem_size, CvMemStor
void icvParseError( CvFileStorage* fs, const char* func_name,
const char* err_msg, const char* source_file, int source_line )
{
char buf[1<<10];
sprintf( buf, "%s(%d): %s", fs->filename, fs->lineno, err_msg );
cvError( CV_StsParseError, func_name, buf, source_file, source_line );
cv::String msg = cv::format("%s(%d): %s", fs->filename, fs->lineno, err_msg);
cv::errorNoReturn(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
}
void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )

@ -262,7 +262,7 @@ void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )
char* icvFSResizeWriteBuffer( CvFileStorage* fs, char* ptr, int len );
int icvCalcStructSize( const char* dt, int initial_size );
int icvCalcElemSize( const char* dt, int initial_size );
void icvParseError( CvFileStorage* fs, const char* func_name, const char* err_msg, const char* source_file, int source_line );
void CV_NORETURN icvParseError( CvFileStorage* fs, const char* func_name, const char* err_msg, const char* source_file, int source_line );
char* icvEncodeFormat( int elem_type, char* dt );
int icvDecodeFormat( const char* dt, int* fmt_pairs, int max_len );
int icvDecodeSimpleFormat( const char* dt );

@ -84,7 +84,9 @@ size_t base64_encode(uint8_t const * src, uint8_t * dst, size_t off, size_t cnt)
switch (rst)
{
case 1U: *dst_cur++ = base64_padding;
/* fallthrough */
case 2U: *dst_cur++ = base64_padding;
/* fallthrough */
default: *dst_cur = 0;
break;
}

@ -1098,6 +1098,7 @@ static float32_t f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool ex
switch ( roundingMode ) {
case round_near_even:
if ( ! fracF32UI( uiA ) ) break;
/* fallthrough */
case round_near_maxMag:
if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
break;
@ -1805,6 +1806,7 @@ static float64_t f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool ex
switch ( roundingMode ) {
case round_near_even:
if ( ! fracF64UI( uiA ) ) break;
/* fallthrough */
case round_near_maxMag:
if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
break;

@ -103,6 +103,7 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool)
{
case COLOR_RGB2HLS: case COLOR_BGR2HLS:
h_limit = 180;
/* fallthrough */
case COLOR_RGB2HLS_FULL: case COLOR_BGR2HLS_FULL:
{
ASSERT_EQ(dst_roi.type(), udst_roi.type());

@ -60,6 +60,13 @@
#pragma warning(disable: 4748)
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
using namespace cv;
namespace cv

Loading…
Cancel
Save