diff --git a/libcxx/include/barrier b/libcxx/include/barrier index e6dc0a19a5c36..5ef8b78e83c44 100644 --- a/libcxx/include/barrier +++ b/libcxx/include/barrier @@ -57,9 +57,7 @@ namespace std # error is not supported on this single threaded system #endif -#if _LIBCPP_STD_VER < 14 -# error requires C++14 or later -#endif +#if _LIBCPP_STD_VER >= 14 _LIBCPP_BEGIN_NAMESPACE_STD @@ -319,4 +317,6 @@ public: _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 14 + #endif //_LIBCPP_BARRIER diff --git a/libcxx/include/latch b/libcxx/include/latch index 7c8b2f52205bc..c83f6bf413688 100644 --- a/libcxx/include/latch +++ b/libcxx/include/latch @@ -49,9 +49,7 @@ namespace std # error is not supported on this single threaded system #endif -#if _LIBCPP_STD_VER < 14 -# error requires C++14 or later -#endif +#if _LIBCPP_STD_VER >= 14 _LIBCPP_BEGIN_NAMESPACE_STD @@ -101,4 +99,6 @@ public: _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 14 + #endif //_LIBCPP_LATCH diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore index 77e3797f7ac63..cd27534d3e85b 100644 --- a/libcxx/include/semaphore +++ b/libcxx/include/semaphore @@ -58,9 +58,7 @@ using binary_semaphore = counting_semaphore<1>; # error is not supported on this single threaded system #endif -#if _LIBCPP_STD_VER < 14 -# error is requires C++14 or later -#endif +#if _LIBCPP_STD_VER >= 14 _LIBCPP_BEGIN_NAMESPACE_STD @@ -230,4 +228,6 @@ using binary_semaphore = counting_semaphore<1>; _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 14 + #endif //_LIBCPP_SEMAPHORE diff --git a/libcxx/test/libcxx/modules/stds_include.sh.cpp b/libcxx/test/libcxx/modules/stds_include.sh.cpp new file mode 100644 index 0000000000000..ce5bfb2a8eef8 --- /dev/null +++ b/libcxx/test/libcxx/modules/stds_include.sh.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Test that we can include libc++ headers when building with modules +// enabled in various Standard modes. This is a common source of breakage +// since the 'std' module will include all headers, so if something in a +// header fails under a standard mode, importing anything will fail. + +// This test fails on Windows because the underlying libc headers on Windows +// are not modular +// XFAIL: LIBCXX-WINDOWS-FIXME + +// FIXME: The header is not supported for single-threaded systems, +// but still gets built as part of the 'std' module, which breaks the build. +// XFAIL: libcpp-has-no-threads + +// REQUIRES: modules-support + +// NOTE: The -std=XXX flag is present in %flags, so we overwrite it by passing it after %flags. +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++98 %s +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++03 %s +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++11 %s +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++14 %s +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++17 %s +// RUN: %cxx %flags %compile_flags -fmodules -fcxx-modules -fsyntax-only -std=c++2a %s + +#include + +int main(int, char**) { + return 0; +}