All the unreachable code reported by clang has been fixed, or
excluded in the drivers where it is in imported base code, so turn
the check on for the whole tree.

Use -Wunreachable-code-aggressive, which adds
-Wunreachable-code-break and -Wunreachable-code-return to the plain
check. Those two find the dead break after a return and the return
after a switch where every case returns.

Note that only clang implements these warnings. GCC rejects
-Wunreachable-code-aggressive and documents -Wunreachable-code as
doing nothing.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 config/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/config/meson.build b/config/meson.build
index 9f501589b7..14c50b501f 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -338,6 +338,7 @@ global_cflags = [
         '-Wsign-compare',
         '-Wstrict-prototypes',
         '-Wundef',
+        '-Wunreachable-code-aggressive',
         '-Wwrite-strings',
 
         # globally disabled warnings
@@ -372,8 +373,11 @@ if cc.has_argument('-Wno-shadow')
     no_shadow_cflag = '-Wno-shadow'
 endif
 
+# test the positive flag, GCC accepts any unknown -Wno-* option
 no_unreachable_cflag = []
-if cc.has_argument('-Wunreachable-code')
+if cc.has_argument('-Wunreachable-code-aggressive')
+    no_unreachable_cflag = '-Wno-unreachable-code-aggressive'
+elif cc.has_argument('-Wunreachable-code')
     no_unreachable_cflag = '-Wno-unreachable-code'
 endif
 
-- 
2.53.0

Reply via email to