fundamental: adjust #if conditional for _fallthrough_ for clang
authorThomas Haller <thaller@redhat.com>
Wed, 6 Jul 2022 12:50:50 +0000 (14:50 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Jul 2022 20:10:23 +0000 (22:10 +0200)
commitda519f8c815baa3849800ddf6c6ffe2bfbabddce
tree5aff55f39b4440a7f9f25387d47a2bc32e827c20
parent132b63bd3131bc72b92adfcfa434fc2ed8648487
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')
src/fundamental/macro-fundamental.h