From d9f06ca585d7dd59811e59b8d783d756501ed32e Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Sun, 29 Nov 2020 13:28:58 +0000
Subject: [PATCH] generic detection of __attribute__((fallthrough))
__has_attribute is supported on gcc >= 5, clang >= 2.9
__attribute__((fallthrough)) is supported on gcc => 7, clang >= 12
Signed-off-by: Andreas Mohr <and@gmx.li>
---
configure.ac | 8 --------
lib/global.h | 6 +++++-
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 98717e682..5b48a1e95 100644
a
|
b
|
if test "x$enable_werror" = xyes; then |
45 | 45 | mc_CHECK_ONE_CFLAG([-Werror]) |
46 | 46 | fi |
47 | 47 | |
48 | | dnl Compiler can generate warnings for unrecognized flags added to CFLAGS |
49 | | dnl which causes attribute checks to fail |
50 | | ax_gcc_func_attribute_save_flags=$[]_AC_LANG_PREFIX[]FLAGS |
51 | | _AC_LANG_PREFIX[]FLAGS= |
52 | | AX_GCC_FUNC_ATTRIBUTE([fallthrough]) |
53 | | _AC_LANG_PREFIX[]FLAGS=$ax_gcc_func_attribute_save_flags |
54 | | unset ax_gcc_func_attribute_save_flags |
55 | | |
56 | 48 | LT_INIT |
57 | 49 | |
58 | 50 | |
diff --git a/lib/global.h b/lib/global.h
index 6bf55952c..cdc2c8e27 100644
a
|
b
|
|
27 | 27 | /* for sig_atomic_t */ |
28 | 28 | #include <signal.h> |
29 | 29 | |
30 | | #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH |
| 30 | #if defined __has_attribute |
| 31 | #if __has_attribute (fallthrough) |
31 | 32 | #define MC_FALLTHROUGH __attribute__((fallthrough)) |
32 | 33 | #else |
33 | 34 | #define MC_FALLTHROUGH |
34 | 35 | #endif |
| 36 | #else |
| 37 | #define MC_FALLTHROUGH |
| 38 | #endif |
35 | 39 | |
36 | 40 | /*** typedefs(not structures) and defined constants **********************************************/ |
37 | 41 | |