]> git.ipfire.org Git - thirdparty/bind9.git/commit
Use C2x [[fallthrough]] when supported by LLVM/clang
authorOndřej Surý <ondrej@isc.org>
Thu, 19 May 2022 19:40:24 +0000 (21:40 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 19 May 2022 20:02:07 +0000 (22:02 +0200)
commit4657b0f0c4fbd57a109e28e2e554a37c00ec39ef
tree0a862d2c32c860720387e1ad1d47d36d3aef7d65
parentdb5f8ebb6f1ee4b308503c0a7af80ce192cd4610
Use C2x [[fallthrough]] when supported by LLVM/clang

Clang added support for the gcc-style fallthrough
attribute (i.e. __attribute__((fallthrough))) in version 10.  However,
__has_attribute(fallthrough) will return 1 in C mode in older versions,
even though they only support the C++11 fallthrough attribute. At best,
the unsupported attribute is simply ignored; at worst, it causes errors.

The C2x fallthrough attribute has the advantages of being supported in
the broadest range of clang versions (added in version 9) and being easy
to check for support. Use C2x [[fallthrough]] attribute if possible, and
fall back to not using an attribute for clang versions that don't have
it.

Courtesy of Joshua Root

(cherry picked from commit 14c8d4386397adbb826e94c4dfe9b7364dab8c75)
lib/isc/include/isc/util.h