← Back to team overview

kicad-developers team mailing list archive

-Wsuggest-override with scripting enabled

 

Hi,

Rather than blanket-disabling -Wsuggest-override when scripting is
enabled, it's possible to turn the warnings off for just the
problematic pcbnew_wrap.cxx file using set_source_file_properties().

This means when building with scripting (which I always do), the
warnings are still enabled for all other files.

Second patch is an override opportunity which was previously silenced
by the blanket disabling of the warning.

Thanks,

John
From 177fad07745c99a6adfb1fee76e235fc1a443234 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Wed, 5 Oct 2016 13:34:04 +0100
Subject: [PATCH 1/2] Disable -Wsuggest-override for scripting files, but not
 other files

This allows the warning to be active for code which would benefit from
it, but not spew hundreds of warnings for code over which KiCad does not
have control of the override specifiers.
---
 CMakeLists.txt        |  4 +---
 pcbnew/CMakeLists.txt | 10 ++++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d96872..e3e0eec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,9 +180,7 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
 
     CHECK_CXX_COMPILER_FLAG("-Wsuggest-override" COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
 
-    # Swig generated files do not use override specifier and create a lot of warnings
-    # So do not use -Wsuggest-override with KICAD_SCRIPTING ON, untill a best way is found
-    if(COMPILER_SUPPORTS_WSUGGEST_OVERRIDE AND NOT KICAD_SCRIPTING)
+    if(COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
     endif()
 endif()
diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 3200d21..a0f281f 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -327,6 +327,16 @@ if( KICAD_SCRIPTING )
         pcbnew_wrap.cxx
         ${PCBNEW_SCRIPTING_PYTHON_HELPERS}
         )
+
+
+    # Swig generated files do not use the override specifier, therefore
+    # disable suggest-override warnings
+    if (COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
+        set_source_files_properties(pcbnew_wrap.cxx
+            PROPERTIES COMPILE_FLAGS -Wno-suggest-override
+        )
+    endif()
+
 endif()
 
 
-- 
2.10.0

From 140b48b80ae55139d15d9a53639045d66ad6357d Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Wed, 5 Oct 2016 14:57:27 +0100
Subject: [PATCH 2/2] Add override specifier in scripting dialog

---
 pcbnew/dialogs/dialog_scripting.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pcbnew/dialogs/dialog_scripting.h b/pcbnew/dialogs/dialog_scripting.h
index deb33b7..a3271d7 100644
--- a/pcbnew/dialogs/dialog_scripting.h
+++ b/pcbnew/dialogs/dialog_scripting.h
@@ -33,7 +33,7 @@ public:
     DIALOG_SCRIPTING( wxWindow * parent );
 
 private:
-    void OnRunButtonClick( wxCommandEvent& event );
+    void OnRunButtonClick( wxCommandEvent& event ) override;
 };
 
 #endif  // _DIALOG_SCRIPTING_H_
-- 
2.10.0


Follow ups