diff options
author | Thomas Haller <thaller@redhat.com> | 2022-07-06 14:50:50 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-06 22:10:23 +0200 |
commit | da519f8c815baa3849800ddf6c6ffe2bfbabddce (patch) | |
tree | 5aff55f39b4440a7f9f25387d47a2bc32e827c20 /src/fundamental/macro-fundamental.h | |
parent | 132b63bd3131bc72b92adfcfa434fc2ed8648487 (diff) | |
download | systemd-da519f8c815baa3849800ddf6c6ffe2bfbabddce.tar.gz |
fundamental: adjust #if conditional for _fallthrough_ for clang
NetworkManager takes systemd sources. It gets compiler warnings
related to _fallthrough_. They probably can also affect systemd
itself.
A) on RHEL-7, gcc 4.8.5-44.el7 we get:
../src/libnm-systemd-shared/src/fundamental/macro-fundamental.h:45:22: error: "__clang__" is not defined [-Werror=undef]
#if __GNUC__ >= 7 || __clang__
^
Presumably gcc older than 7 is supported, so fix this.
B) on Ubuntu 18.04, clang 1:6.0-41~exp5~ubuntu1 we get:
../src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c:746:17: error: declaration does not declare anything [-Werror,-Wmissing-declarations]
_fallthrough_;
^
../src/libnm-systemd-shared/src/fundamental/macro-fundamental.h:46:25: note: expanded from macro '_fallthrough_'
# define _fallthrough_ __attribute__((__fallthrough__))
^
Granted, README comments that clang >= 10 is required. However,
parts of systemd build just fine with older clang. It seems unnecessary
to break this and the fix helps NetworkManager.
Fixes: c0f5d58c9ab7 ('meson: Document why -Wimplicit-fallthrough is not used with clang')
Diffstat (limited to 'src/fundamental/macro-fundamental.h')
-rw-r--r-- | src/fundamental/macro-fundamental.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 3c38afcab8..a738b1f50e 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -42,7 +42,7 @@ # define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__))) #endif -#if __GNUC__ >= 7 || __clang__ +#if __GNUC__ >= 7 || (defined(__clang__) && __clang_major__ >= 10) # define _fallthrough_ __attribute__((__fallthrough__)) #else # define _fallthrough_ |