From 09944a83d9f9970b97e5d71b963276023a5c86f6 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Thu, 6 Jul 2023 19:27:16 +0300 Subject: [PATCH] build: w/a compiler warnings for GCC 11-12 and Clang 13, reduce build output --- 3rdparty/protobuf/CMakeLists.txt | 1 + cmake/copy_files.cmake | 12 +++++----- modules/calib3d/test/test_solvepnp_ransac.cpp | 4 ++-- modules/core/test/test_mat.cpp | 23 ++++++++++++------- .../include/opencv2/gapi/util/variant.hpp | 9 ++++++++ modules/imgproc/src/floodfill.cpp | 7 ++++++ modules/java/generator/gen_java.py | 4 ++-- modules/ts/include/opencv2/ts/ts_gtest.h | 15 ++++++------ 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/3rdparty/protobuf/CMakeLists.txt b/3rdparty/protobuf/CMakeLists.txt index e39de9823a..5e8e3a9ed2 100644 --- a/3rdparty/protobuf/CMakeLists.txt +++ b/3rdparty/protobuf/CMakeLists.txt @@ -26,6 +26,7 @@ else() -Wsuggest-override -Winconsistent-missing-override -Wimplicit-fallthrough -Warray-bounds # GCC 9+ + -Wstringop-overflow -Wstringop-overread # GCC 11-12 ) endif() if(CV_ICC) diff --git a/cmake/copy_files.cmake b/cmake/copy_files.cmake index 423f7fff9c..f7e13a45d4 100644 --- a/cmake/copy_files.cmake +++ b/cmake/copy_files.cmake @@ -21,7 +21,7 @@ macro(copy_file_ src dst prefix) endif() if(use_symlink) if(local_update OR NOT IS_SYMLINK "${dst}") - message("${prefix}Symlink: '${dst_name}' ...") + #message("${prefix}Symlink: '${dst_name}' ...") endif() get_filename_component(target_path "${dst}" PATH) file(MAKE_DIRECTORY "${target_path}") @@ -38,7 +38,7 @@ macro(copy_file_ src dst prefix) set(local_update 1) endif() if(local_update) - message("${prefix}Copying: '${dst_name}' ...") + #message("${prefix}Copying: '${dst_name}' ...") configure_file(${src} ${dst} COPYONLY) else() #message("${prefix}Up-to-date: '${dst_name}'") @@ -55,7 +55,7 @@ if(NOT DEFINED COPYLIST_VAR) set(COPYLIST_VAR "COPYLIST") endif() list(LENGTH ${COPYLIST_VAR} __length) -message("${prefix}... ${__length} entries (${COPYLIST_VAR})") +#message("${prefix}... ${__length} entries (${COPYLIST_VAR})") foreach(id ${${COPYLIST_VAR}}) set(src "${${COPYLIST_VAR}_SRC_${id}}") set(dst "${${COPYLIST_VAR}_DST_${id}}") @@ -80,7 +80,7 @@ foreach(id ${${COPYLIST_VAR}}) endif() file(GLOB_RECURSE _files RELATIVE "${src}" ${src_glob}) list(LENGTH _files __length) - message("${prefix} ... directory '.../${src_name2}/${src_name}' with ${__length} files") + #message("${prefix} ... directory '.../${src_name2}/${src_name}' with ${__length} files") foreach(f ${_files}) if(NOT EXISTS "${src}/${f}") message(FATAL_ERROR "COPY ERROR: Source file is missing: ${src}/${f}") @@ -98,12 +98,12 @@ else() endif() if(NOT "${__state}" STREQUAL "${__prev_state}") file(WRITE "${STATE_FILE}" "${__state}") - message("${prefix}Updated!") + #message("${prefix}Updated!") set(update_dephelper 1) endif() if(NOT update_dephelper) - message("${prefix}All files are up-to-date.") + #message("${prefix}All files are up-to-date.") elseif(DEFINED DEPHELPER) file(WRITE "${DEPHELPER}" "") endif() diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index 43b90dff92..759b9650a8 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -1531,8 +1531,8 @@ TEST(Calib3d_SolvePnP, generic) } else { - p3f = p3f_; - p2f = p2f_; + p3f = vector(p3f_.begin(), p3f_.end()); + p2f = vector(p2f_.begin(), p2f_.end()); } vector reprojectionErrors; diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 2d6019eac4..aea0507149 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -18,7 +18,7 @@ class Core_ReduceTest : public cvtest::BaseTest public: Core_ReduceTest() {} protected: - void run( int); + void run( int) CV_OVERRIDE; int checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim ); int checkCase( int srcType, int dstType, int dim, Size sz ); int checkDim( int dim, Size sz ); @@ -495,7 +495,7 @@ public: Core_ArrayOpTest(); ~Core_ArrayOpTest(); protected: - void run(int); + void run(int) CV_OVERRIDE; }; @@ -599,6 +599,11 @@ static void setValue(SparseMat& M, const int* idx, double value, RNG& rng) CV_Error(CV_StsUnsupportedFormat, ""); } +#if defined(__GNUC__) && (__GNUC__ == 11 || __GNUC__ == 12) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + template struct InitializerFunctor{ /// Initializer for cv::Mat::forEach test @@ -621,6 +626,11 @@ struct InitializerFunctor5D{ } }; +#if defined(__GNUC__) && (__GNUC__ == 11 || __GNUC__ == 12) +#pragma GCC diagnostic pop +#endif + + template struct EmptyFunctor { @@ -1023,7 +1033,7 @@ class Core_MergeSplitBaseTest : public cvtest::BaseTest protected: virtual int run_case(int depth, size_t channels, const Size& size, RNG& rng) = 0; - virtual void run(int) + virtual void run(int) CV_OVERRIDE { // m is Mat // mv is vector @@ -1068,7 +1078,7 @@ public: ~Core_MergeTest() {} protected: - virtual int run_case(int depth, size_t matCount, const Size& size, RNG& rng) + virtual int run_case(int depth, size_t matCount, const Size& size, RNG& rng) CV_OVERRIDE { const int maxMatChannels = 10; @@ -1126,7 +1136,7 @@ public: ~Core_SplitTest() {} protected: - virtual int run_case(int depth, size_t channels, const Size& size, RNG& rng) + virtual int run_case(int depth, size_t channels, const Size& size, RNG& rng) CV_OVERRIDE { Mat src(size, CV_MAKETYPE(depth, (int)channels)); rng.fill(src, RNG::UNIFORM, 0, 100, true); @@ -1990,7 +2000,6 @@ TEST(Core_InputArray, fetch_MatExpr) } -#ifdef CV_CXX11 class TestInputArrayRangeChecking { static const char *kind2str(cv::_InputArray ia) { @@ -2137,8 +2146,6 @@ TEST(Core_InputArray, range_checking) { TestInputArrayRangeChecking::run(); } -#endif - TEST(Core_Vectors, issue_13078) { diff --git a/modules/gapi/include/opencv2/gapi/util/variant.hpp b/modules/gapi/include/opencv2/gapi/util/variant.hpp index f412110deb..48b55646c5 100644 --- a/modules/gapi/include/opencv2/gapi/util/variant.hpp +++ b/modules/gapi/include/opencv2/gapi/util/variant.hpp @@ -509,6 +509,11 @@ namespace util return v.index() == util::variant::template index_of(); } +#if defined(__GNUC__) && (__GNUC__ == 11 || __GNUC__ == 12) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + template bool operator==(const variant &lhs, const variant &rhs) { @@ -524,6 +529,10 @@ namespace util return (eqs[lhs.index()])(lhs.memory, rhs.memory); } +#if defined(__GNUC__) && (__GNUC__ == 11 || __GNUC__ == 12) +#pragma GCC diagnostic pop +#endif + template bool operator!=(const variant &lhs, const variant &rhs) { diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 926c48e65d..91beca2a99 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -560,8 +560,15 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, if( depth == CV_8U ) for( i = 0; i < cn; i++ ) { +#if defined(__GNUC__) && (__GNUC__ == 12) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif ld_buf.b[i] = saturate_cast(cvFloor(loDiff[i])); ud_buf.b[i] = saturate_cast(cvFloor(upDiff[i])); +#if defined(__GNUC__) && (__GNUC__ == 12) +#pragma GCC diagnostic pop +#endif } else if( depth == CV_32S ) for( i = 0; i < cn; i++ ) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 6f07ad913d..7b301193e5 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -686,7 +686,7 @@ class JavaWrapperGenerator(object): msg = "// Return type '%s' is not supported, skipping the function\n\n" % fi.ctype self.skipped_func_list.append(c_decl + "\n" + msg) j_code.write( " "*4 + msg ) - logging.warning("SKIP:" + c_decl.strip() + "\t due to RET type " + fi.ctype) + logging.info("SKIP:" + c_decl.strip() + "\t due to RET type " + fi.ctype) return for a in fi.args: if a.ctype not in type_dict: @@ -698,7 +698,7 @@ class JavaWrapperGenerator(object): msg = "// Unknown type '%s' (%s), skipping the function\n\n" % (a.ctype, a.out or "I") self.skipped_func_list.append(c_decl + "\n" + msg) j_code.write( " "*4 + msg ) - logging.warning("SKIP:" + c_decl.strip() + "\t due to ARG type " + a.ctype + "/" + (a.out or "I")) + logging.info("SKIP:" + c_decl.strip() + "\t due to ARG type " + a.ctype + "/" + (a.out or "I")) return self.ported_func_list.append(c_decl) diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h index b1c6c12152..b6a953592f 100644 --- a/modules/ts/include/opencv2/ts/ts_gtest.h +++ b/modules/ts/include/opencv2/ts/ts_gtest.h @@ -17501,6 +17501,7 @@ CartesianProductHolder2(const Generator1& g1, const Generator2& g2) static_cast >(g2_))); } + CartesianProductHolder2(const CartesianProductHolder2 & other) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder2& other) = delete; @@ -17523,7 +17524,7 @@ CartesianProductHolder3(const Generator1& g1, const Generator2& g2, static_cast >(g2_), static_cast >(g3_))); } - + CartesianProductHolder3(const CartesianProductHolder3 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder3& other) = delete; @@ -17549,7 +17550,7 @@ CartesianProductHolder4(const Generator1& g1, const Generator2& g2, static_cast >(g3_), static_cast >(g4_))); } - + CartesianProductHolder4(const CartesianProductHolder4 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder4& other) = delete; @@ -17577,7 +17578,7 @@ CartesianProductHolder5(const Generator1& g1, const Generator2& g2, static_cast >(g4_), static_cast >(g5_))); } - + CartesianProductHolder5(const CartesianProductHolder5 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder5& other) = delete; @@ -17609,7 +17610,7 @@ CartesianProductHolder6(const Generator1& g1, const Generator2& g2, static_cast >(g5_), static_cast >(g6_))); } - + CartesianProductHolder6(const CartesianProductHolder6 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder6& other) = delete; @@ -17644,7 +17645,7 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2, static_cast >(g6_), static_cast >(g7_))); } - + CartesianProductHolder7(const CartesianProductHolder7 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder7& other) = delete; @@ -17683,7 +17684,7 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2, static_cast >(g7_), static_cast >(g8_))); } - + CartesianProductHolder8(const CartesianProductHolder8 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder8& other) = delete; @@ -17726,7 +17727,7 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2, static_cast >(g8_), static_cast >(g9_))); } - + CartesianProductHolder9(const CartesianProductHolder9 &) = default; private: // No implementation - assignment is unsupported. void operator=(const CartesianProductHolder9& other) = delete;