]> 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:01:59 +0000 (22:01 +0200)
commitb4521486eda03bddae8970392f6277d88ceb96db
treef3ecf77b40683f146ea9afbe45ae7230fbcb01d0
parent4dde80f6551cd694dd0d3b5bec4d9f0beb6fcae0
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