Ticket #4103: mc-4103-2-generic-detection-of-attribute-fallthrough.patch

File mc-4103-2-generic-detection-of-attribute-fallthrough.patch, 1.5 KB (added by and, 21 months ago)
  • configure.ac

    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 
    4545    mc_CHECK_ONE_CFLAG([-Werror]) 
    4646fi 
    4747 
    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  
    5648LT_INIT 
    5749 
    5850 
  • lib/global.h

    diff --git a/lib/global.h b/lib/global.h
    index 6bf55952c..cdc2c8e27 100644
    a b  
    2727/* for sig_atomic_t */ 
    2828#include <signal.h> 
    2929 
    30 #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH 
     30#if defined __has_attribute 
     31#if __has_attribute (fallthrough) 
    3132#define MC_FALLTHROUGH __attribute__((fallthrough)) 
    3233#else 
    3334#define MC_FALLTHROUGH 
    3435#endif 
     36#else 
     37#define MC_FALLTHROUGH 
     38#endif 
    3539 
    3640/*** typedefs(not structures) and defined constants **********************************************/ 
    3741