On Tue, Jun 14, 2022 at 9:25 AM Darren Kenny <darren.ke...@oracle.com> wrote: > > The use of variable-length arrays (VLAs) is disabled by default in > clang 9 and above. > > The same pragma that works for GCC also works for clang, so check for > clang 9+ too. > > Signed-off-by: Darren Kenny <darren.ke...@oracle.com> > --- > lib/regex.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/regex.h b/lib/regex.h > index a7e0bd027570..5295f62a9abf 100644 > --- a/lib/regex.h > +++ b/lib/regex.h > @@ -531,7 +531,8 @@ typedef struct > # endif > #endif > > -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) > +#if (defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)) \ > + || __clang_major__ >= 9 > # pragma GCC diagnostic push > # pragma GCC diagnostic ignored "-Wvla" > #endif > @@ -688,7 +689,8 @@ extern size_t regerror (int __errcode, const regex_t > *_Restrict_ __preg, > > extern void regfree (regex_t *__preg); > > -#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) > +#if (defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)) \ > + || __clang_major__ >= 9 > # pragma GCC diagnostic pop > #endif
LLVM's Clang 9.0 was released September 2021. That corresponds to Xcode 13 and Apple's Clang 13.0. I don't think it's enough to simply use __clang_major__. Xcode 10 will be captured, but it does not support it. I think you should use __apple_build_version__ to differentiate between Apple Clang and LLVM Clang. Jeff