From 16e623362003276d161d941791f33397f74cbcdf Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Thu, 7 May 2020 23:32:36 +0300 Subject: [PATCH] Fix implicit fallthrough warning with gcc 9.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../daemon/escape.c: In function ‘escape’: ../daemon/escape.c:49:10: error: this statement may fall through [-Werror=implicit-fallthrough=] 49 | if ((flags & LADISH_ESCAPE_FLAG_OTHER) == 0) | ^ ../daemon/escape.c:53:5: note: here 53 | case '<': /* invalid attribute value char (XML spec) */ | ^~~~ gcc (Gentoo 9.3.0 p2) 9.3.0 --- daemon/escape.c | 1 + wscript | 3 +++ 2 files changed, 4 insertions(+) diff --git a/daemon/escape.c b/daemon/escape.c index 1d4e0ccd..727ffdb9 100644 --- a/daemon/escape.c +++ b/daemon/escape.c @@ -50,6 +50,7 @@ void escape(const char ** src_ptr, char ** dst_ptr, unsigned int flags) { break; } + /* fall through intentionally, some compilers are parsing comments */ case '<': /* invalid attribute value char (XML spec) */ case '&': /* invalid attribute value char (XML spec) */ case '"': /* we store attribute values in double quotes - invalid attribute value char (XML spec) */ diff --git a/wscript b/wscript index a7594716..a785f34f 100644 --- a/wscript +++ b/wscript @@ -224,6 +224,9 @@ def configure(conf): if not conf.env['BUILD_PYLASH']: add_cflag(conf, '-Wextra') conf.env.append_unique('CXXFLAGS', '-Wno-unused-parameter') # the UNUSED() macro doesnt work for C++ + + add_cflag(conf, '-Wimplicit-fallthrough=2') + if conf.env['BUILD_WERROR']: add_cflag(conf, '-Werror') # for pre gcc-4.4, enable optimizations so use of uninitialized variables gets detected