From 7887dc0c7690b277d4c138d5e27d925cff26c4cd Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 17 May 2021 15:56:38 -0700 Subject: [PATCH] Fixed the __has_attribute() check for old versions of Clang. --- upb/port_def.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/upb/port_def.inc b/upb/port_def.inc index 0f9a157bea..75d416d1ce 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -167,12 +167,20 @@ /* Configure whether fasttable is switched on or not. *************************/ -#if defined(__clang__) && __has_attribute(musttail) +#ifdef __has_attribute +#define UPB_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +#define UPB_HAS_ATTRIBUTE(x) 0 +#endif + +#if UPB_HAS_ATTRIBUTE(musttail) #define UPB_MUSTTAIL __attribute__((musttail)) #else #define UPB_MUSTTAIL #endif +#undef UPB_HAS_ATTRIBUTE + /* This check is not fully robust: it does not require that we have "musttail" * support available. We need tail calls to avoid consuming arbitrary amounts * of stack space.