From 8018934a58e904f3da0197db38c674da17e86ae3 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 13 Aug 2024 05:47:44 -0400 Subject: [PATCH] Make ATTRIBUTE_FALLTHROUGH work cross-compiler (#836) * Make ATTRIBUTE_FALLTHROUGH work cross-compiler Current code doesn't work on LLVM. This should fix it so it works on gcc and llvm. * Update internal.h --- src/internal.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/internal.h b/src/internal.h index 482648a65..6922a838c 100644 --- a/src/internal.h +++ b/src/internal.h @@ -191,8 +191,12 @@ /* Allow falling through in switch statements for the few cases where that is needed */ #ifndef ATTRIBUTE_FALLTHROUGH -# if __GNUC_PREREQ (7, 0) -# define ATTRIBUTE_FALLTHROUGH __attribute__ ((fallthrough)) +# if defined __has_attribute +# if __has_attribute (fallthrough) +# define ATTRIBUTE_FALLTHROUGH __attribute__ ((fallthrough)) +# else +# define ATTRIBUTE_FALLTHROUGH +# endif # else # define ATTRIBUTE_FALLTHROUGH # endif