diff --git a/libcxx/include/atomic b/libcxx/include/atomic index 75af5de33ca4c..fba7040f6900c 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -598,7 +598,10 @@ template # define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 0 # endif -# if _LIBCPP_STD_VER < 23 && _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED +// The Android LLVM toolchain has historically allowed combining the +// and headers in dialects before C++23, so for backwards +// compatibility, preserve that ability when targeting Android. +# if _LIBCPP_STD_VER < 23 && !defined(__ANDROID__) && _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED # error is incompatible with before C++23. Please compile with -std=c++23. # endif diff --git a/libcxx/include/stdatomic.h b/libcxx/include/stdatomic.h index 2991030eee456..dc1a955b69cb6 100644 --- a/libcxx/include/stdatomic.h +++ b/libcxx/include/stdatomic.h @@ -126,7 +126,10 @@ using std::atomic_signal_fence // see below # pragma GCC system_header # endif -# if defined(__cplusplus) && _LIBCPP_STD_VER >= 23 +// The Android LLVM toolchain has historically allowed combining the +// and headers in dialects before C++23, so for backwards +// compatibility, preserve that ability when targeting Android. +# if defined(__cplusplus) && (_LIBCPP_STD_VER >= 23 || defined(__ANDROID__)) # include # include diff --git a/libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp b/libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp index 349dc51aaa0e6..c997e4b792459 100644 --- a/libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp @@ -7,7 +7,10 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: no-threads -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// On Android, libc++'s header always redirects to , even before C++23. +// UNSUPPORTED: c++03 +// UNSUPPORTED: (c++11 || c++14 || c++17 || c++20) && !android // This test verifies that redirects to . diff --git a/libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp b/libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp index a788ea32dddc8..7d14fa308bf06 100644 --- a/libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp +++ b/libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp @@ -9,6 +9,9 @@ // UNSUPPORTED: no-threads // REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20 +// On Android, libc++'s header always redirects to , even before C++23. +// XFAIL: android + // No diagnostic gets emitted when we build with modules. // XFAIL: clang-modules-build diff --git a/libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp b/libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp index a8a99e6937f31..5c966c6bca6e2 100644 --- a/libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp +++ b/libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp @@ -21,6 +21,9 @@ // doesn't work at all if we don't use the provided by libc++ in C++23 and above. // XFAIL: (c++11 || c++14 || c++17 || c++20) && gcc +// On Android, libc++'s header always redirects to , even before C++23. +// XFAIL: android + #include #include #include