On Tuesday, June 13, 2017 10:26:00 AM CEST Philipp Psurek wrote:
GCC 7.1.0 complains about an intended fallthrough. “__attribute__ ((fallthrough))” in this part of code would suppress this warning. Because older GCC compiler don’t understand this statement attribute and because there is already a comment in the source containing “falls?[ \t-]*thr(ough|u)” we can suppress the warning with the “-Wimplicit-fallthrough=2” warning option. Unintended fallthroughs without a comment will trigger this warning.
Older GCC compiler don’t understand this warning option and exits with error. There has to be a compiler recognition after that only GCC =>7.1.0 receives this option.
Signed-off-by: Philipp Psurek philipp.psurek@gmail.com
Makefile | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/Makefile b/Makefile index 6bebb7d..29b7e2f 100755 --- a/Makefile +++ b/Makefile @@ -101,6 +101,11 @@ MKDIR ?= mkdir -p COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
+# Check for GCC >=7 +ifeq ($(shell $(CC) -x c++ --std=c++17 -E -P - <<< __cplusplus),201703L)
CFLAGS += -Wimplicit-fallthrough=2
+endif
Hmm, I don't like this one too much, since it looks cryptic and we will have to add up new versions, which I'd like to avoid.
Did you try to change the wording? I've googled a bit and it seems a comment containing the wording "fallthrough" will avoid it. Maybe we should just change "fall through" to "fallthrough"?
Thanks, Simon