Clang: only use [[fallthrough]] in C++ files

It appears that [[fallthrough]] is valid in C++ but not in C. And
in some Clang versions (e.g. Clang 11 on macOS), Clang is pedantic
about this and considers it an error to use [[fallthrough]] in a
.c file such as src/util/format.c.

This changes makes gcc_fallthrough a no-op under Clang in C files.
This commit is contained in:
Jacob Vosmaer 2019-12-30 21:50:33 +01:00 committed by Max Kellermann
parent b9a7f30443
commit dca0519336
2 changed files with 2 additions and 1 deletions

1
NEWS
View File

@ -1,4 +1,5 @@
ver 0.21.19 (not yet released)
* fix build failure with clang 10
ver 0.21.18 (2019/12/24)
* protocol

View File

@ -145,7 +145,7 @@
#if GCC_CHECK_VERSION(7,0)
#define gcc_fallthrough __attribute__((fallthrough))
#elif CLANG_CHECK_VERSION(10,0)
#elif CLANG_CHECK_VERSION(10,0) && defined(__cplusplus)
#define gcc_fallthrough [[fallthrough]]
#else
#define gcc_fallthrough