Skip to content

Commit 054a218

Browse files
committed
autoconf: optional implicit-fallthrough
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
1 parent 7d9c1b4 commit 054a218

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ AC_DEFINE_UNQUOTED([SOF_MICRO], sof_micro, [Sof micro version])
1818

1919
AC_CANONICAL_HOST
2020

21+
# Macro to set flag if supported
22+
AC_DEFUN([ADD_OPTIONAL_AM_CFLAGS],
23+
[SAVED_CFLAGS="$CFLAGS"
24+
CFLAGS="-Werror $1"
25+
AC_MSG_CHECKING([whether $CC supports $1])
26+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
27+
[AC_MSG_RESULT([yes])]
28+
[AM_CFLAGS="$AM_CFLAGS $1"],
29+
[AC_MSG_RESULT([no])])
30+
CFLAGS="$SAVED_CFLAGS"])
31+
2132
# General assembler flags
2233
ASFLAGS="-DASSEMBLY"
2334
AC_SUBST(ASFLAGS)
@@ -63,9 +74,11 @@ AM_CONDITIONAL(BUILD_LIB, test "$have_library" = "yes")
6374

6475
# check if we are building tools
6576
AC_ARG_ENABLE(rimage, [AS_HELP_STRING([--enable-rimage],[build rimage tool])], have_rimage=$enableval, have_rimage=no)
77+
IMPLICIT_FALLTHROUGH_FLAG=""
6678
if test "$have_rimage" = "yes"; then
6779
AC_DEFINE([CONFIG_RIMAGE], [1], [Configure to build rimage])
6880
AM_CFLAGS="-O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes"
81+
IMPLICIT_FALLTHROUGH_FLAG="-Wimplicit-fallthrough=3"
6982
fi
7083
AM_CONDITIONAL(BUILD_RIMAGE, test "$have_rimage" = "yes")
7184

@@ -118,6 +131,7 @@ case "$with_arch" in
118131

119132
# automake FLAGS defined here
120133
AM_CFLAGS="-O3 -Wall -Werror -Wl,-EL -Wmissing-prototypes"
134+
IMPLICIT_FALLTHROUGH_FLAG="-Wimplicit-fallthrough=3"
121135
AM_LDFLAGS="-lpthread"
122136
AM_CCASFLAGS="-O3 -Wall -Werror -Wl,-EL -Wmissing-prototypes"
123137

@@ -131,6 +145,8 @@ case "$with_arch" in
131145
;;
132146
esac
133147

148+
ADD_OPTIONAL_AM_CFLAGS([-Wimplicit-fallthrough=3])
149+
134150
AC_SUBST(ARCH_CFLAGS)
135151
AC_SUBST(ARCH_LDFLAGS)
136152

rimage/manifest.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static int man_copy_sram(struct image *image, Elf32_Shdr *section,
143143
break;
144144
case SHT_NOBITS:
145145
seg_type = SOF_MAN_SEGMENT_BSS;
146+
/* FALLTHRU */
146147
default:
147148
return 0;
148149
}

0 commit comments

Comments
 (0)