From dca0519336586be95b920004178114a097681768 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 30 Dec 2019 21:50:33 +0100 Subject: [PATCH] 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. --- NEWS | 1 + src/util/Compiler.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index bb541bba3..83388e38a 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/src/util/Compiler.h b/src/util/Compiler.h index 96f63fae4..04e49bb61 100644 --- a/src/util/Compiler.h +++ b/src/util/Compiler.h @@ -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