Re: Apple LLVM 10 and `__fallthrough__`

2023-02-27 Thread Alexei Podtelezhnikov
> > > -# elif (__GNUC__ >= 7) || (__clang_major__ >= 10)
> > > +# elif ((__GNUC__ >= 7) \
> > > +|| (defined __apple_build_version__ \
> > > +? __apple_build_version__ >= 1400 \
> > > +: __clang_major__ >= 10))
> > >
> > > Wiki suggests __apple_build_version__ >= 1200
> > > https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2

Alternative Xcode versioning source found:
https://github.com/gsl-lite/gsl-lite/blob/master/include/gsl/gsl-lite.hpp#L534-L557



Re: Apple LLVM 10 and `__fallthrough__`

2023-02-26 Thread Alexei Podtelezhnikov
On Sun, Feb 26, 2023 at 7:08 PM Bruno Haible  wrote:
>
> Alexei Podtelezhnikov wrote:
> > -# elif (__GNUC__ >= 7) || (__clang_major__ >= 10)
> > +# elif ((__GNUC__ >= 7) \
> > +|| (defined __apple_build_version__ \
> > +? __apple_build_version__ >= 1400 \
> > +: __clang_major__ >= 10))
> >
> > Wiki suggests __apple_build_version__ >= 1200
> > https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2
>
> Interesting. Can you test it (by compiling Werner's test program from
> <https://lists.gnu.org/archive/html/bug-gnulib/2023-02/msg00159.html>
> on an Xcode version between 12.0 and 12.4)?

I wish I could directly test it. However, I could confirm that Swift
release 5.3 (Xcode 12) was the first release with this line
https://github.com/apple/llvm-project/blob/swift-5.3-RELEASE/clang/test/Sema/fallthrough-attr.c#L18



Re: Apple LLVM 10 and `__fallthrough__`

2023-02-26 Thread Alexei Podtelezhnikov
-# elif (__GNUC__ >= 7) || (__clang_major__ >= 10)
+# elif ((__GNUC__ >= 7) \
+|| (defined __apple_build_version__ \
+? __apple_build_version__ >= 1400 \
+: __clang_major__ >= 10))

Wiki suggests __apple_build_version__ >= 1200
https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2

Would  it perhaps be better if clang used [[fallthrough]]  instead of
__attribute__((fallthrough))? They have supported [[fallthrough]]
since at least 3.5.0 circa 2014. In this particular case they are
ahead of GCC and towards the standard acceptance.
https://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html

There was also a suggestion on this list to use __has_attribute.
https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00267.html