Adjust handling of -Wsuggest-override
authorCarl Hetherington <cth@carlh.net>
Thu, 21 Apr 2022 12:22:08 +0000 (14:22 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 21 Apr 2022 12:22:50 +0000 (14:22 +0200)
It seems that on older GCCs (e.g. the one from Ubuntu 18.04) the
pragma to temporarily turn off this warning does not work, so here
we only use it on newer GCCs where we can turn it off for libraries
that trigger the warning (mostly asdcplib, but also wxWidgets).

src/lib/warnings.h
wscript

index ca8a9ab5e5ee209c87aa4aa53e4f91b36c7fbfec..c6c2f7e0c89e4e83c2e480b08e06c6fb73ab19e1 100644 (file)
@@ -35,8 +35,7 @@
   _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \
   _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
   _Pragma("GCC diagnostic ignored \"-Waddress\"") \
-  _Pragma("GCC diagnostic ignored \"-Wparentheses\"") \
-  _Pragma("GCC diagnostic ignored \"-Wsuggest-override\"")
+  _Pragma("GCC diagnostic ignored \"-Wparentheses\"")
 #endif
 
 #define DCPOMATIC_ENABLE_WARNINGS \
diff --git a/wscript b/wscript
index 4ccadf6fd3dfdfef13b91d3d6389d2f5e169aae4..994f1b6f3e7aee7c90de95c21dba1272849f3cff 100644 (file)
--- a/wscript
+++ b/wscript
@@ -109,7 +109,6 @@ def configure(conf):
                                        '-Wall',
                                        '-Wextra',
                                        '-Wwrite-strings',
-                                       '-Wsuggest-override',
                                        '-Wno-error=deprecated',
                                        # I tried and failed to ignore these with _Pragma
                                        '-Wno-ignored-qualifiers',
@@ -127,6 +126,10 @@ def configure(conf):
         if int(gcc[0]) >= 8:
             # I tried and failed to ignore these with _Pragma
             conf.env.append_value('CXXFLAGS', ['-Wno-cast-function-type'])
+        if int(gcc[0]) >= 9:
+            # I can't get #pragma GCC diagnostic ignored "-Wsuggest-override" to work on older GCCs,
+            # so only enable this if we're on a newer one
+            conf.env.append_value('CXXFLAGS', '-Wsuggest-override')
         have_c11 = int(gcc[0]) >= 4 and int(gcc[1]) >= 8 and int(gcc[2]) >= 1
         # Most gccs still give these warnings from boost::optional
         conf.env.append_value('CXXFLAGS', ['-Wno-maybe-uninitialized'])