[pacman-dev] Add implicit fall through warning

Message ID 20190212013011.5233-1-allan@archlinux.org
State Accepted, archived
Headers show
Series [pacman-dev] Add implicit fall through warning | expand

Commit Message

Allan McRae Feb. 12, 2019, 1:30 a.m. UTC
Requires modification to our comment about fall through to match compilers
expectations.  Works for GCC and Clang.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
 configure.ac        | 1 +
 meson.build         | 1 +
 src/pacman/pacman.c | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/configure.ac b/configure.ac
index 415ed3cb..2f345b5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -462,6 +462,7 @@  if test "x$warningflags" = "xyes" ; then
 	CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS])
+	CFLAGS_ADD([-Wimplicit-fallthrough], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS])
 	CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS])
diff --git a/meson.build b/meson.build
index 0a710653..02a3a3d3 100644
--- a/meson.build
+++ b/meson.build
@@ -220,6 +220,7 @@  if get_option('buildtype').startswith('debug')
     '-Wformat-nonliteral',
     '-Wformat-security',
     '-Wignored-qualifiers',
+    '-Wimplicit-fallthrough',
     '-Winit-self',
     '-Wlogical-op',
     '-Wmissing-declarations',
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index a2a420b6..3bb622e6 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -196,7 +196,7 @@  static void usage(int op, const char * const myname)
 				addlist(_("      --ignore <pkg>   ignore a package upgrade (can be used more than once)\n"));
 				addlist(_("      --ignoregroup <grp>\n"
 				          "                       ignore a group upgrade (can be used more than once)\n"));
-				/* pass through */
+				/* fall through */
 			case PM_OP_REMOVE:
 				addlist(_("  -d, --nodeps         skip dependency version checks (-dd to skip all checks)\n"));
 				addlist(_("      --assume-installed <package=version>\n"