summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-21 13:22:23 +0100
committerThomas Haller <thaller@redhat.com>2020-02-21 18:27:40 +0100
commit86dfc4b099fd686e0fc70cd63bde9871dcf0ee43 (patch)
tree5007efb08e1a628beba8c8a6c6346c5576c1b11b /m4
parentffa098edae563e35ffbb50b20e306fbfa3d5617a (diff)
downloadNetworkManager-86dfc4b099fd686e0fc70cd63bde9871dcf0ee43.tar.gz
build: disable -Wimplicit-fallthrough warning with clang
Seems clang 10 got support for -Wimplicit-fallthrough, but does not honor the code comments to suppress the warning. What a disaster. Try to detect it. See-also: https://github.com/ClangBuiltLinux/linux/issues/ #636 See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2079e93f562c7f7a030eb7642017ee5eabaaa10
Diffstat (limited to 'm4')
-rw-r--r--m4/compiler_options.m421
1 files changed, 20 insertions, 1 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4
index 3ceccd983f..9adc1f14c3 100644
--- a/m4/compiler_options.m4
+++ b/m4/compiler_options.m4
@@ -70,7 +70,6 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
-Wfloat-equal \
-Wformat-nonliteral \
-Wformat-security \
- -Wimplicit-fallthrough \
-Wimplicit-function-declaration \
-Winit-self \
-Wlogical-op \
@@ -137,6 +136,26 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
[G_DEFINE_TYPE (NMObject, nm_object, G_TYPE_OBJECT)]
)
+ dnl clang started supporting -Wimplicit-fallthrough, but it does not
+ dnl honor the code comments to suppress the warning. Disable the
+ dnl warning with clang.
+ dnl
+ NM_COMPILER_WARNING([$1], [implicit-fallthrough],
+ [int foo(int a);
+ int foo(int a) {
+ int r = 0;
+ switch (a) {
+ case 1:
+ r++;
+ /* fall-through */
+ case 2:
+ r++;
+ break;
+ }
+ return r;
+ }]
+ )
+
eval "AS_TR_SH([$1])='$CFLAGS_MORE_WARNINGS $$1'"
else
AC_MSG_RESULT(no)