diff --git a/.github/workflows/build-and-test-multiplatform.yml b/.github/workflows/build-and-test-multiplatform.yml index 9a3715798e..0c774d4893 100644 --- a/.github/workflows/build-and-test-multiplatform.yml +++ b/.github/workflows/build-and-test-multiplatform.yml @@ -71,7 +71,9 @@ jobs: -D USE_VTK=ON ` -D USE_TBB=ON ` -D USE_RAPIDJSON=ON ` - -D USE_OPENGL=ON .. + -D USE_OPENGL=ON ` + -D CMAKE_CXX_FLAGS="/W4 /WX" ` + -D CMAKE_C_FLAGS="/W4 /WX" .. shell: pwsh - name: Build OCCT @@ -141,7 +143,9 @@ jobs: -D USE_VTK=OFF ` -D USE_TBB=ON ` -D USE_RAPIDJSON=ON ` - -D USE_OPENGL=ON .. + -D USE_OPENGL=ON ` + -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" ` + -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" .. shell: pwsh - name: Build OCCT @@ -193,7 +197,9 @@ jobs: -D USE_DRACO=ON \ -D USE_FREETYPE=ON \ -D USE_OPENGL=ON \ - -D USE_FREEIMAGE=ON .. + -D USE_FREEIMAGE=ON \ + -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ + -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" .. - name: Build OCCT run: | @@ -244,7 +250,9 @@ jobs: -D USE_DRACO=ON \ -D USE_FREETYPE=ON \ -D USE_OPENGL=ON \ - -D USE_FREEIMAGE=ON .. + -D USE_FREEIMAGE=ON \ + -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ + -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" .. - name: Build OCCT run: | @@ -298,7 +306,9 @@ jobs: -D USE_VTK=ON \ -D USE_TBB=OFF \ -D USE_RAPIDJSON=ON \ - -D USE_OPENGL=ON .. + -D USE_OPENGL=ON \ + -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ + -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" .. - name: Build OCCT run: | diff --git a/adm/cmake/occt_defs_flags.cmake b/adm/cmake/occt_defs_flags.cmake index de5d59643f..ac2e2eda5d 100644 --- a/adm/cmake/occt_defs_flags.cmake +++ b/adm/cmake/occt_defs_flags.cmake @@ -38,6 +38,10 @@ else() else() add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() + if (APPLE) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + endif() add_definitions(-DOCC_CONVERT_SIGNALS) endif() @@ -152,9 +156,14 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPIL # Link-Time Code Generation(LTCG) is requared for Whole Program Optimisation(GL) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections") - set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections") - set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto") + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -flto") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto") + if (NOT WIN32) + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") + endif() endif() if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32") @@ -173,8 +182,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]") # CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated. set (CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") endif() - # Optimize size of binaries - set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") + if (NOT WIN32) + # Optimize size of binaries + set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") + endif() endif() if(MINGW) add_definitions(-D_WIN32_WINNT=0x0601) diff --git a/src/Aspect/Aspect_OpenVRSession.cxx b/src/Aspect/Aspect_OpenVRSession.cxx index 2c295435f6..e95450cabe 100644 --- a/src/Aspect/Aspect_OpenVRSession.cxx +++ b/src/Aspect/Aspect_OpenVRSession.cxx @@ -1038,13 +1038,13 @@ void Aspect_OpenVRSession::ProcessEvents() { case Aspect_XRActionType_InputDigital: { - Aspect_XRDigitalActionData aData = GetDigitalActionData (anAction); + //Aspect_XRDigitalActionData aData = GetDigitalActionData (anAction); //if (aData.IsChanged) { std::cout << " " << anAction->Id() << " pressed: " << aData.IsPressed << "\n"; } break; } case Aspect_XRActionType_InputAnalog: { - Aspect_XRAnalogActionData aData = GetAnalogActionData (anAction); + //Aspect_XRAnalogActionData aData = GetAnalogActionData (anAction); //if (aData.IsChanged()) { std::cout << " " << anAction->Id() << " changed: " << aData.VecXYZ[0] << " " << aData.VecXYZ[1] << " " << aData.VecXYZ[2] << "\n"; } break; } @@ -1053,6 +1053,8 @@ void Aspect_OpenVRSession::ProcessEvents() GetPoseActionDataForNextFrame (anAction); break; } + default: + break; } } } diff --git a/src/ExpToCasExe/exptocas.tab.cxx b/src/ExpToCasExe/exptocas.tab.cxx index f213ed2006..725caec05a 100644 --- a/src/ExpToCasExe/exptocas.tab.cxx +++ b/src/ExpToCasExe/exptocas.tab.cxx @@ -496,7 +496,6 @@ namespace exptocas { int yylen = 0; // Error handling. - int yynerrs_ = 0; int yyerrstatus_ = 0; /// The lookahead symbol. @@ -933,7 +932,6 @@ namespace exptocas { // If not already recovering from an error, report this error. if (!yyerrstatus_) { - ++yynerrs_; std::string msg = YY_("syntax error"); error (YY_MOVE (msg)); } diff --git a/src/IVtkDraw/IVtkDraw_Interactor.hxx b/src/IVtkDraw/IVtkDraw_Interactor.hxx index f81d659d3b..199bc3ff42 100644 --- a/src/IVtkDraw/IVtkDraw_Interactor.hxx +++ b/src/IVtkDraw/IVtkDraw_Interactor.hxx @@ -49,9 +49,9 @@ public: vtkTypeMacro (IVtkDraw_Interactor, vtkRenderWindowInteractor) - virtual void Initialize(); - virtual void Enable(); - virtual void Start() { } + virtual void Initialize() Standard_OVERRIDE; + virtual void Enable() Standard_OVERRIDE; + virtual void Start() Standard_OVERRIDE { } const PSelector& Selector() const { return mySelector; } void SetShapePicker (const PSelector& theSelector); @@ -97,7 +97,7 @@ protected: void OnMouseWheelBackward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); #else static void ProcessEvents (ClientData theData, int); - void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY); + void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY) Standard_OVERRIDE; #endif private: diff --git a/src/IVtkTools/IVtkTools_DisplayModeFilter.hxx b/src/IVtkTools/IVtkTools_DisplayModeFilter.hxx index 72ee21188a..31520a9cef 100644 --- a/src/IVtkTools/IVtkTools_DisplayModeFilter.hxx +++ b/src/IVtkTools/IVtkTools_DisplayModeFilter.hxx @@ -35,7 +35,7 @@ public: vtkTypeMacro(IVtkTools_DisplayModeFilter,IVtkTools_SubPolyDataFilter) static IVtkTools_DisplayModeFilter *New(); - void PrintSelf (std::ostream& os, vtkIndent indent); + void PrintSelf (std::ostream& os, vtkIndent indent) Standard_OVERRIDE; //! Set display mode to define cells types to be passed through this filter. void SetDisplayMode (const IVtk_DisplayMode aMode); diff --git a/src/IVtkTools/IVtkTools_SubPolyDataFilter.hxx b/src/IVtkTools/IVtkTools_SubPolyDataFilter.hxx index 709f08823d..cbdff5af79 100644 --- a/src/IVtkTools/IVtkTools_SubPolyDataFilter.hxx +++ b/src/IVtkTools/IVtkTools_SubPolyDataFilter.hxx @@ -35,7 +35,7 @@ public: vtkTypeMacro(IVtkTools_SubPolyDataFilter,vtkPolyDataAlgorithm) static IVtkTools_SubPolyDataFilter *New(); - void PrintSelf (std::ostream& theOs, vtkIndent theIndent); + void PrintSelf (std::ostream& theOs, vtkIndent theIndent) Standard_OVERRIDE; //! Set ids to be passed through this filter. void SetData(const IVtk_IdTypeMap theSet); diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 6750ed5f29..e90300e9c4 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -2193,13 +2193,18 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Woverflow" +#elif defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable: 4307) #endif - constexpr Standard_Integer i=IntegerLast(); + constexpr Standard_Integer i = IntegerLast(); Standard_Integer res = i + 1; #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #pragma GCC diagnostic pop +#elif defined(_MSC_VER) + #pragma warning(pop) #endif di << "Not caught: " << i << " + 1 = " << res << ", still OK\n"; } diff --git a/src/ShapeProcess/ShapeProcess.cxx b/src/ShapeProcess/ShapeProcess.cxx index d8bf36688e..e099ce0d46 100644 --- a/src/ShapeProcess/ShapeProcess.cxx +++ b/src/ShapeProcess/ShapeProcess.cxx @@ -225,7 +225,9 @@ Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theCo std::vector> ShapeProcess::getOperators(const OperationsFlags& theFlags) { std::vector> aResult; - for (std::underlying_type::type anOperation = Operation::First; anOperation < Operation::Count; ++anOperation) + for (std::underlying_type::type anOperation = static_cast::type>(Operation::First); + anOperation <= static_cast::type>(Operation::Last); + ++anOperation) { if (theFlags.test(anOperation)) { diff --git a/src/ShapeProcess/ShapeProcess.hxx b/src/ShapeProcess/ShapeProcess.hxx index ac4d9fab94..623897a012 100644 --- a/src/ShapeProcess/ShapeProcess.hxx +++ b/src/ShapeProcess/ShapeProcess.hxx @@ -39,8 +39,7 @@ public: DEFINE_STANDARD_ALLOC //! Describes all available operations. - //! C++11 enum class is not used to allow implicit conversion to undelying type. - enum Operation : uint8_t + enum class Operation : uint8_t { First = 0, // First operation index. DirectFaces = First, @@ -61,7 +60,7 @@ public: FixShape, SplitClosedEdges, SplitCommonVertex, - Count // Number of operations. + Last = SplitCommonVertex // Last operation index. }; // Bitset of operations. It is used to specify which operations should be performed. @@ -70,7 +69,7 @@ public: // flags.set(ShapeProcess::Operation::DirectFaces); // flags.set(ShapeProcess::Operation::SameParameter); // ShapeProcess::Perform(context, flags); - using OperationsFlags = std::bitset; + using OperationsFlags = std::bitset(Operation::Last) + 1>; public: //! Registers operator to make it visible for Performer diff --git a/src/StepFile/lex.step.cxx b/src/StepFile/lex.step.cxx index bbbbbc310c..2436b0f008 100644 --- a/src/StepFile/lex.step.cxx +++ b/src/StepFile/lex.step.cxx @@ -1318,7 +1318,7 @@ int yyFlexLexer::LexerInput( char* buf, int max_size ) if ( yyin.bad() ) return -1; else - return yyin.gcount(); + return static_cast(yyin.gcount()); #endif } diff --git a/src/StepFile/step.tab.cxx b/src/StepFile/step.tab.cxx index 7ce8463992..e86fbf346e 100644 --- a/src/StepFile/step.tab.cxx +++ b/src/StepFile/step.tab.cxx @@ -437,7 +437,6 @@ namespace step { int yylen = 0; // Error handling. - int yynerrs_ = 0; int yyerrstatus_ = 0; /// The lookahead symbol. @@ -681,7 +680,6 @@ namespace step { // If not already recovering from an error, report this error. if (!yyerrstatus_) { - ++yynerrs_; context yyctx (*this, yyla); std::string msg = yysyntax_error_ (yyctx); error (YY_MOVE (msg));