Index: libcxx/CREDITS.TXT =================================================================== --- libcxx/CREDITS.TXT +++ libcxx/CREDITS.TXT @@ -184,3 +184,12 @@ N: Zhihao Yuan E: lichray@gmail.com D: Standard compatibility fixes. + +N: Damien Lebrun-Grandie +E: dalg24@gmail.com +E: lebrungrandt@ornl.gov +D: Implementation of mdspan. + +N: Christian Trott +E: crtrott@sandia.gov +D: Implementation of mdspan. Index: libcxx/include/CMakeLists.txt =================================================================== --- libcxx/include/CMakeLists.txt +++ libcxx/include/CMakeLists.txt @@ -439,6 +439,7 @@ __iterator/wrap_iter.h __locale __mbstate_t.h + __mdspan/extents.h __memory/addressof.h __memory/align.h __memory/aligned_alloc.h @@ -853,6 +854,7 @@ locale.h map math.h + mdspan memory memory_resource mutex Index: libcxx/include/__mdspan/extents.h =================================================================== --- /dev/null +++ libcxx/include/__mdspan/extents.h @@ -0,0 +1,527 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering +// Solutions of Sandia, LLC (NTESS). +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___MDSPAN_EXTENTS_H +#define _LIBCPP___MDSPAN_EXTENTS_H + +/* + extents synopsis + +namespace std { + template + class extents { + public: + using index_type = _IndexType; + using size_type = make_unsigned_t; + using rank_type = size_t; + + // [mdspan.extents.obs], observers of the multidimensional index space + static constexpr rank_type rank() noexcept { return sizeof...(_Extents); } + static constexpr rank_type rank_dynamic() noexcept { return dynamic-index(rank()); } + static constexpr size_t static_extent(rank_type) noexcept; + constexpr index_type extent(rank_type) const noexcept; + + // [mdspan.extents.cons], constructors + constexpr extents() noexcept = default; + + template + constexpr explicit(see below) + extents(const extents<_OtherIndexType, _OtherExtents...>&) noexcept; + template + constexpr explicit extents(_OtherIndexTypes...) noexcept; + template + constexpr explicit(N != rank_dynamic()) + extents(span<_OtherIndexType, N>) noexcept; + template + constexpr explicit(N != rank_dynamic()) + extents(const array<_OtherIndexType, N>&) noexcept; + + // [mdspan.extents.cmp], comparison operators + template + friend constexpr bool operator==(const extents&, + const extents<_OtherIndexType, _OtherExtents...>&) noexcept; + + // [mdspan.extents.expo], exposition-only helpers + constexpr size_t fwd-prod-of-extents(rank_type) const noexcept; // exposition only + constexpr size_t __rev-prod-of-extents(rank_type) const noexcept; // exposition only + template + static constexpr auto index-cast(_OtherIndexType&&) noexcept; // exposition only + + private: + static constexpr rank_type dynamic-index(rank_type) noexcept; // exposition only + static constexpr rank_type dynamic-index-inv(rank_type) noexcept; // exposition only + array dynamic-extents{}; // exposition only + }; + + template + explicit extents(Integrals...) + -> see below; +} +*/ + +#include <__assert> +#include <__config> +#include <__fwd/array.h> +#include <__type_traits/is_convertible.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_same.h> +#include <__type_traits/make_unsigned.h> +#include <__utility/move.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +namespace __mdspan_detail { + +// ------------------------------------------------------------------ +// ------------ __static_array -------------------------------------- +// ------------------------------------------------------------------ +// array like class which provides an array of static values with get + +// Implementation of Static Array with recursive implementation of get. +template +struct __static_array_impl; + +template +struct __static_array_impl<_Idx, _Tp, _FirstExt, _Extents...> { + constexpr static _Tp get(size_t __r) noexcept { + if (__r == _Idx) + return _FirstExt; + else + return __static_array_impl<_Idx + 1, _Tp, _Extents...>::get(__r); + } + template + constexpr static _Tp get() { + if constexpr (__r == _Idx) + return _FirstExt; + else + return __static_array_impl<_Idx + 1, _Tp, _Extents...>::template get<__r>(); + } +}; + +// End the recursion +template +struct __static_array_impl<_Idx, _Tp, _FirstExt> { + constexpr static _Tp get(size_t) noexcept { return _FirstExt; } + template + constexpr static _Tp get() { + return _FirstExt; + } +}; + +// Don't start recursion if size 0 +template +struct __static_array_impl<0, _Tp> { + constexpr static _Tp get(size_t) noexcept { return _Tp(); } + template + constexpr static _Tp get() { + return _Tp(); + } +}; + +// Static array, provides get(), get(r) and operator[r] +template +struct __static_array : public __static_array_impl<0, _Tp, _Values...> { +public: + constexpr static size_t size() { return sizeof...(_Values); } +}; + +// ------------------------------------------------------------------ +// ------------ index_sequence_scan --------------------------------- +// ------------------------------------------------------------------ + +// index_sequence_scan takes compile time values and provides get(r) +// which return the sum of the first r-1 values. + +// Recursive implementation for get +template +struct __index_sequence_scan_impl; + +template +struct __index_sequence_scan_impl<_Idx, _FirstVal, _Values...> { + constexpr static size_t get(size_t __r) { + if (__r > _Idx) + return _FirstVal + __index_sequence_scan_impl<_Idx + 1, _Values...>::get(__r); + else + return 0; + } +}; + +template +struct __index_sequence_scan_impl<_Idx, _FirstVal> { +# if defined(__NVCC__) || defined(__NVCOMPILER) + // NVCC warns about pointless comparison with 0 for _Idx==0 and r being const + // evaluatable and also 0. + constexpr static size_t get(size_t __r) { + return static_cast(_Idx) > static_cast(__r) ? _FirstVal : 0; + } +# else + constexpr static size_t get(size_t __r) { return _Idx > __r ? _FirstVal : 0; } +# endif +}; +template <> +struct __index_sequence_scan_impl<0> { + constexpr static size_t get(size_t) { return 0; } +}; + +// ------------------------------------------------------------------ +// ------------ __possibly_empty_array ----------------------------- +// ------------------------------------------------------------------ + +// array like class which provides get function and operator [], and +// has a specialization for the size 0 case. +// This is needed to make the __maybe_static_array be truly empty, for +// all static values. + +template +struct __possibly_empty_array { + _Tp __vals_[_Num]; + constexpr _Tp& operator[](size_t __r) { return __vals_[__r]; } + constexpr const _Tp& operator[](size_t __r) const { return __vals_[__r]; } +}; + +template +struct __possibly_empty_array<_Tp, 0> { + constexpr _Tp operator[](size_t) { return _Tp(); } + constexpr const _Tp operator[](size_t) const { return _Tp(); } +}; + +// ------------------------------------------------------------------ +// ------------ __maybe_static_array -------------------------------- +// ------------------------------------------------------------------ + +// array like class which has a mix of static and runtime values but +// only stores the runtime values. +// The type of the static and the runtime values can be different. +// The position of a dynamic value is indicated through a tag value. +template +struct __maybe_static_array { + static_assert(is_convertible<_TStatic, _TDynamic>::value, + "__maybe_static_array: _TStatic must be convertible to _TDynamic"); + static_assert(is_convertible<_TDynamic, _TStatic>::value, + "__maybe_static_array: _TDynamic must be convertible to _TStatic"); + +private: + // Static values member + using __static_vals_t = __static_array<_TStatic, _Values...>; + constexpr static size_t __size_ = sizeof...(_Values); + constexpr static size_t __size_dynamic_ = ((_Values == _DynTag) + ... + 0); + + // Dynamic values member + [[no_unique_address]] __possibly_empty_array<_TDynamic, __size_dynamic_> __dyn_vals_; + + // static mapping of indices to the position in the dynamic values array + using __dyn_map_t = __index_sequence_scan_impl<0, static_cast(_Values == _DynTag)...>; + +public: + constexpr __maybe_static_array() = default; + + // constructor for all static values + // TODO: add precondition check? + template + requires((__size_dynamic_ == 0) && (sizeof...(_Vals) > 0)) + constexpr __maybe_static_array(_Vals...) : __dyn_vals_{} {} + + // constructors from dynamic values only + template + requires(sizeof...(_DynVals) == __size_dynamic_ && __size_dynamic_ > 0) + constexpr __maybe_static_array(_DynVals... __vals) : __dyn_vals_{static_cast<_TDynamic>(__vals)...} {} + + template + requires(_Num == __size_dynamic_ && _Num > 0) + constexpr __maybe_static_array(const std::array<_Tp, _Num>& __vals) { + for (size_t __r = 0; __r < _Num; __r++) + __dyn_vals_[__r] = static_cast<_TDynamic>(__vals[__r]); + } + + template + requires(_Num == __size_dynamic_ && _Num == 0) + constexpr __maybe_static_array(const std::array<_Tp, _Num>&) : __dyn_vals_{} {} + + template + requires(_Num == __size_dynamic_ && _Num > 0) + constexpr __maybe_static_array(const std::span<_Tp, _Num>& __vals) { + for (size_t __r = 0; __r < _Num; __r++) + __dyn_vals_[__r] = static_cast<_TDynamic>(__vals[__r]); + } + + template + requires(_Num == __size_dynamic_ && _Num == 0) + constexpr __maybe_static_array(const std::span<_Tp, _Num>&) : __dyn_vals_{} {} + + // constructors from all values + template + requires(sizeof...(_DynVals) != __size_dynamic_ && __size_dynamic_ > 0) + constexpr __maybe_static_array(_DynVals... __vals) { + static_assert((sizeof...(_DynVals) == __size_), "Invalid number of values."); + _TDynamic __values[__size_]{static_cast<_TDynamic>(__vals)...}; + for (size_t __r = 0; __r < __size_; __r++) { + _TStatic __static_val = __static_vals_t::get(__r); + if (__static_val == _DynTag) { + __dyn_vals_[__dyn_map_t::get(__r)] = __values[__r]; + } + // Precondition check + else + _LIBCPP_ASSERT(__values[__r] == static_cast<_TDynamic>(__static_val), + "extents construction: mismatch of provided arguments with static extents."); + } + } + + template + requires(_Num != __size_dynamic_ && __size_dynamic_ > 0) + constexpr __maybe_static_array(const std::array<_Tp, _Num>& __vals) { + static_assert((_Num == __size_), "Invalid number of values."); + for (size_t __r = 0; __r < __size_; __r++) { + _TStatic __static_val = __static_vals_t::get(__r); + if (__static_val == _DynTag) { + __dyn_vals_[__dyn_map_t::get(__r)] = static_cast<_TDynamic>(__vals[__r]); + } + // Precondition check + else + _LIBCPP_ASSERT(static_cast<_TDynamic>(__vals[__r]) == static_cast<_TDynamic>(__static_val), + "extents construction: mismatch of provided arguments with static extents."); + } + } + + template + requires(_Num != __size_dynamic_ && __size_dynamic_ > 0) + constexpr __maybe_static_array(const std::span<_Tp, _Num>& __vals) { + static_assert((_Num == __size_) || (__size_ == dynamic_extent)); + for (size_t __r = 0; __r < __size_; __r++) { + _TStatic __static_val = __static_vals_t::get(__r); + if (__static_val == _DynTag) { + __dyn_vals_[__dyn_map_t::get(__r)] = static_cast<_TDynamic>(__vals[__r]); + } + // Precondition check + else + _LIBCPP_ASSERT(static_cast<_TDynamic>(__vals[__r]) == static_cast<_TDynamic>(__static_val), + "extents construction: mismatch of provided arguments with static extents."); + } + } + + // access functions + constexpr static _TStatic __static_value(size_t __r) noexcept { return __static_vals_t::get(__r); } + + constexpr _TDynamic __value(size_t __r) const { + _TStatic __static_val = __static_vals_t::get(__r); + return __static_val == _DynTag ? __dyn_vals_[__dyn_map_t::get(__r)] : static_cast<_TDynamic>(__static_val); + } + constexpr _TDynamic operator[](size_t __r) const { return __value(__r); } + + // observers + constexpr static size_t __size() { return __size_; } + constexpr static size_t __size_dynamic() { return __size_dynamic_; } +}; + +} // namespace __mdspan_detail + +// ------------------------------------------------------------------ +// ------------ extents --------------------------------------------- +// ------------------------------------------------------------------ + +// Class to describe the extents of a multi dimensional array. +// Used by mdspan, mdarray and layout mappings. +// See ISO C++ standard [mdspan.extents] + +template +class extents { +public: + // typedefs for integral types used + using index_type = _IndexType; + using size_type = make_unsigned_t; + using rank_type = size_t; + + static_assert(std::is_integral::value && !std::is_same::value, + "extents::index_type must be a signed or unsigned integer type"); + +private: + constexpr static rank_type __rank_ = sizeof...(_Extents); + constexpr static rank_type __rank_dynamic_ = ((_Extents == dynamic_extent) + ... + 0); + + // internal storage type using __maybe_static_array + using __vals_t = __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>; + [[no_unique_address]] __vals_t __vals_; + +public: + // [mdspan.extents.obs], observers of multidimensional index space + constexpr static rank_type rank() noexcept { return __rank_; } + constexpr static rank_type rank_dynamic() noexcept { return __rank_dynamic_; } + + constexpr index_type extent(rank_type __r) const noexcept { return __vals_.__value(__r); } + constexpr static size_t static_extent(rank_type __r) noexcept { return __vals_t::__static_value(__r); } + + // [mdspan.extents.cons], constructors + constexpr extents() noexcept = default; + + // Construction from just dynamic or all values. + // Precondition check is deferred to __maybe_static_array constructor + template + requires((is_convertible_v<_OtherIndexTypes, index_type> && ...) && + (is_nothrow_constructible_v && ...) && + (sizeof...(_OtherIndexTypes) == __rank_ || sizeof...(_OtherIndexTypes) == __rank_dynamic_)) + constexpr explicit extents(_OtherIndexTypes... __dynvals) noexcept : __vals_(static_cast(__dynvals)...) {} + + template + requires(is_convertible_v<_OtherIndexType, index_type> && is_nothrow_constructible_v && + (_Num == __rank_ || _Num == __rank_dynamic_)) + explicit(_Num != __rank_dynamic_) constexpr extents(const array<_OtherIndexType, _Num>& __exts) noexcept + : __vals_(std::move(__exts)) {} + + template + requires(is_convertible_v<_OtherIndexType, index_type> && is_nothrow_constructible_v && + (_Num == __rank_ || _Num == __rank_dynamic_)) + explicit(_Num != __rank_dynamic_) constexpr extents(const span<_OtherIndexType, _Num>& __exts) noexcept + : __vals_(std::move(__exts)) {} + +private: + // Function to construct extents storage from other extents. + // With C++ 17 the first two variants could be collapsed using if constexpr + // in which case you don't need all the requires clauses. + // in C++ 14 mode that doesn't work due to infinite recursion + template + requires((_Idx < __rank_) && (static_extent(_Idx) == dynamic_extent)) + __vals_t __construct_vals_from_extents( + std::integral_constant, + std::integral_constant, + const _OtherExtents& __exts, + _DynamicValues... __dynamic_values) noexcept { + return __construct_vals_from_extents( + std::integral_constant(), + std::integral_constant(), + __exts, + __dynamic_values..., + __exts.extent(_Idx)); + } + + template + requires((_Idx < __rank_) && (static_extent(_Idx) != dynamic_extent)) + __vals_t __construct_vals_from_extents( + std::integral_constant, + std::integral_constant, + const _OtherExtents& __exts, + _DynamicValues... __dynamic_values) noexcept { + return __construct_vals_from_extents( + std::integral_constant(), + std::integral_constant(), + __exts, + __dynamic_values...); + } + + template + requires((_Idx == __rank_) && (_DynCount == __rank_dynamic_)) + __vals_t __construct_vals_from_extents( + std::integral_constant, + std::integral_constant, + const _OtherExtents&, + _DynamicValues... __dynamic_values) noexcept { + return __vals_t{static_cast(__dynamic_values)...}; + } + +public: + // Converting constructor from other extents specializations + template + requires((sizeof...(_OtherExtents) == sizeof...(_Extents)) && + ((_OtherExtents == dynamic_extent || _Extents == dynamic_extent || _OtherExtents == _Extents) && ...)) + explicit( + (((_Extents != dynamic_extent) && (_OtherExtents == dynamic_extent)) || ...) || + (static_cast>(numeric_limits::max()) < + static_cast>( + numeric_limits<_OtherIndexType>::max()))) constexpr extents(const extents<_OtherIndexType, _OtherExtents...>& + __other) noexcept + : __vals_(__construct_vals_from_extents( + std::integral_constant(), std::integral_constant(), __other)) {} + + // Comparison operator + template + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator==(const extents& __lhs, const extents<_OtherIndexType, _OtherExtents...>& __rhs) noexcept { + bool __value = true; + if constexpr (rank() != sizeof...(_OtherExtents)) { + __value = false; + } else { + for (rank_type __r = 0; __r < __rank_; __r++) + __value &= static_cast(__rhs.extent(__r)) == __lhs.extent(__r); + } + return __value; + } + + template + _LIBCPP_HIDE_FROM_ABI friend constexpr bool + operator!=(extents const& __lhs, extents<_OtherIndexType, _OtherExtents...> const& __rhs) noexcept { + return !(__lhs == __rhs); + } +}; + +// Recursive helper classes to implement dextents alias for extents +namespace __mdspan_detail { + +template > +struct __make_dextents; + +template +struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> { + using type = + typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type; +}; + +template +struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { + using type = extents<_IndexType, _ExtentsPack...>; +}; + +} // end namespace __mdspan_detail + +// [mdspan.extents.dextents], alias template +template +using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type; + +// Deduction guide for extents +template +extents(_IndexTypes...) -> extents; + +// Helper type traits for identifying a class as extents. +namespace __mdspan_detail { + +template +struct __is_extents : ::std::false_type {}; + +template +struct __is_extents> : ::std::true_type {}; + +template +inline constexpr bool __is_extents_v = __is_extents<_Tp>::value; + +} // namespace __mdspan_detail + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MDSPAN_EXTENTS_H Index: libcxx/include/libcxx.imp =================================================================== --- libcxx/include/libcxx.imp +++ libcxx/include/libcxx.imp @@ -32,6 +32,7 @@ { include: [ "@<__fwd/.*>", "private", "", "public" ] }, { include: [ "@<__ios/.*>", "private", "", "public" ] }, { include: [ "@<__iterator/.*>", "private", "", "public" ] }, + { include: [ "@<__mdspan/.*>", "private", "", "public" ] }, { include: [ "@<__memory/.*>", "private", "", "public" ] }, { include: [ "@<__memory_resource/.*>", "private", "", "public" ] }, { include: [ "@<__mutex/.*>", "private", "", "public" ] }, Index: libcxx/include/mdspan =================================================================== --- /dev/null +++ libcxx/include/mdspan @@ -0,0 +1,29 @@ +// -*-C++ - *- +//===----------------------------------------------------------------------===// +// +// 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 +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP_MDSPAN +#define _LIBCPP_MDSPAN + +#include <__config> +#include <__mdspan/extents.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP_MDSPAN Index: libcxx/include/module.modulemap.in =================================================================== --- libcxx/include/module.modulemap.in +++ libcxx/include/module.modulemap.in @@ -1119,6 +1119,15 @@ export initializer_list export * } + module mdspan { + header "mdspan" + export span + export * + + module __mdspan { + module extents { private header "__mdspan/extents.h" } + } + } module memory { header "memory" export * Index: libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp =================================================================== --- libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp +++ libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp @@ -426,342 +426,348 @@ // RUN: %{build} -DTEST_71 #if defined(TEST_71) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_72 #if defined(TEST_72) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_73 -#if defined(TEST_73) && !defined(_LIBCPP_HAS_NO_THREADS) -# include +#if defined(TEST_73) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_74 -#if defined(TEST_74) -# include +#if defined(TEST_74) && !defined(_LIBCPP_HAS_NO_THREADS) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_75 #if defined(TEST_75) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_76 #if defined(TEST_76) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_77 #if defined(TEST_77) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_78 -#if defined(TEST_78) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include +#if defined(TEST_78) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_79 -#if defined(TEST_79) -# include +#if defined(TEST_79) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_80 #if defined(TEST_80) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_81 #if defined(TEST_81) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_82 #if defined(TEST_82) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_83 -#if defined(TEST_83) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include +#if defined(TEST_83) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_84 -#if defined(TEST_84) -# include +#if defined(TEST_84) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_85 -#if defined(TEST_85) && !defined(_LIBCPP_HAS_NO_THREADS) -# include +#if defined(TEST_85) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_86 -#if defined(TEST_86) -# include +#if defined(TEST_86) && !defined(_LIBCPP_HAS_NO_THREADS) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_88 -#if defined(TEST_88) && !defined(_LIBCPP_HAS_NO_THREADS) -# include +// RUN: %{build} -DTEST_87 +#if defined(TEST_87) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_89 -#if defined(TEST_89) -# include +#if defined(TEST_89) && !defined(_LIBCPP_HAS_NO_THREADS) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_90 #if defined(TEST_90) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_91 -#if defined(TEST_91) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include +#if defined(TEST_91) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_92 -#if defined(TEST_92) +#if defined(TEST_92) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include + using HandlerType = decltype(std::__libcpp_verbose_abort); +#endif + +// RUN: %{build} -DTEST_93 +#if defined(TEST_93) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_96 -#if defined(TEST_96) +// RUN: %{build} -DTEST_97 +#if defined(TEST_97) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_100 -#if defined(TEST_100) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +// RUN: %{build} -DTEST_101 +#if defined(TEST_101) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_101 -#if defined(TEST_101) +// RUN: %{build} -DTEST_102 +#if defined(TEST_102) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_103 -#if defined(TEST_103) +// RUN: %{build} -DTEST_104 +#if defined(TEST_104) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_104 -#if defined(TEST_104) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +// RUN: %{build} -DTEST_105 +#if defined(TEST_105) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_105 -#if defined(TEST_105) +// RUN: %{build} -DTEST_106 +#if defined(TEST_106) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_107 -#if defined(TEST_107) && !defined(_LIBCPP_HAS_NO_THREADS) -# include - using HandlerType = decltype(std::__libcpp_verbose_abort); -#endif - // RUN: %{build} -DTEST_108 -#if defined(TEST_108) -# include +#if defined(TEST_108) && !defined(_LIBCPP_HAS_NO_THREADS) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_109 #if defined(TEST_109) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_110 #if defined(TEST_110) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_111 #if defined(TEST_111) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_113 -#if defined(TEST_113) -# include +// RUN: %{build} -DTEST_112 +#if defined(TEST_112) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_114 #if defined(TEST_114) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_115 #if defined(TEST_115) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_116 #if defined(TEST_116) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_117 #if defined(TEST_117) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_118 #if defined(TEST_118) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_119 #if defined(TEST_119) -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif -// RUN: %{build} -DTEST_122 -#if defined(TEST_122) && __cplusplus >= 201103L -# include +// RUN: %{build} -DTEST_120 +#if defined(TEST_120) +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_123 #if defined(TEST_123) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_124 #if defined(TEST_124) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_125 #if defined(TEST_125) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_126 #if defined(TEST_126) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_127 #if defined(TEST_127) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_128 #if defined(TEST_128) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_129 -#if defined(TEST_129) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L -# include +#if defined(TEST_129) && __cplusplus >= 201103L +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_130 -#if defined(TEST_130) && __cplusplus >= 201103L -# include +#if defined(TEST_130) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_131 #if defined(TEST_131) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_132 #if defined(TEST_132) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_133 #if defined(TEST_133) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_134 #if defined(TEST_134) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_135 #if defined(TEST_135) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_136 #if defined(TEST_136) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_137 #if defined(TEST_137) && __cplusplus >= 201103L -# include +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_138 -#if defined(TEST_138) -# include +#if defined(TEST_138) && __cplusplus >= 201103L +# include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif // RUN: %{build} -DTEST_139 #if defined(TEST_139) +# include + using HandlerType = decltype(std::__libcpp_verbose_abort); +#endif + +// RUN: %{build} -DTEST_140 +#if defined(TEST_140) # include using HandlerType = decltype(std::__libcpp_verbose_abort); #endif Index: libcxx/test/libcxx/clang_tidy.sh.cpp =================================================================== --- libcxx/test/libcxx/clang_tidy.sh.cpp +++ libcxx/test/libcxx/clang_tidy.sh.cpp @@ -139,6 +139,7 @@ #endif #include #include +#include #include #include #if !defined(_LIBCPP_HAS_NO_THREADS) Index: libcxx/test/libcxx/double_include.sh.cpp =================================================================== --- libcxx/test/libcxx/double_include.sh.cpp +++ libcxx/test/libcxx/double_include.sh.cpp @@ -140,6 +140,7 @@ #endif #include #include +#include #include #include #if !defined(_LIBCPP_HAS_NO_THREADS) Index: libcxx/test/libcxx/min_max_macros.compile.pass.cpp =================================================================== --- libcxx/test/libcxx/min_max_macros.compile.pass.cpp +++ libcxx/test/libcxx/min_max_macros.compile.pass.cpp @@ -211,6 +211,8 @@ TEST_MACROS(); #include TEST_MACROS(); +#include +TEST_MACROS(); #include TEST_MACROS(); #include Index: libcxx/test/libcxx/modules_include.sh.cpp =================================================================== --- libcxx/test/libcxx/modules_include.sh.cpp +++ libcxx/test/libcxx/modules_include.sh.cpp @@ -473,417 +473,422 @@ // RUN: echo 'TEST_71=$!' >> %t.sh // RUN: echo "wait $TEST_55" >> %t.sh #if defined(TEST_71) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_72 &' >> %t.sh // RUN: echo 'TEST_72=$!' >> %t.sh // RUN: echo "wait $TEST_56" >> %t.sh #if defined(TEST_72) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_73 &' >> %t.sh // RUN: echo 'TEST_73=$!' >> %t.sh // RUN: echo "wait $TEST_57" >> %t.sh -#if defined(TEST_73) && !defined(_LIBCPP_HAS_NO_THREADS) -#include +#if defined(TEST_73) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_74 &' >> %t.sh // RUN: echo 'TEST_74=$!' >> %t.sh // RUN: echo "wait $TEST_58" >> %t.sh -#if defined(TEST_74) -#include +#if defined(TEST_74) && !defined(_LIBCPP_HAS_NO_THREADS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_75 &' >> %t.sh // RUN: echo 'TEST_75=$!' >> %t.sh // RUN: echo "wait $TEST_59" >> %t.sh #if defined(TEST_75) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_76 &' >> %t.sh // RUN: echo 'TEST_76=$!' >> %t.sh // RUN: echo "wait $TEST_60" >> %t.sh #if defined(TEST_76) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_77 &' >> %t.sh // RUN: echo 'TEST_77=$!' >> %t.sh // RUN: echo "wait $TEST_61" >> %t.sh #if defined(TEST_77) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_78 &' >> %t.sh // RUN: echo 'TEST_78=$!' >> %t.sh // RUN: echo "wait $TEST_62" >> %t.sh -#if defined(TEST_78) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#include +#if defined(TEST_78) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_79 &' >> %t.sh // RUN: echo 'TEST_79=$!' >> %t.sh // RUN: echo "wait $TEST_63" >> %t.sh -#if defined(TEST_79) -#include +#if defined(TEST_79) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_80 &' >> %t.sh // RUN: echo 'TEST_80=$!' >> %t.sh // RUN: echo "wait $TEST_64" >> %t.sh #if defined(TEST_80) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_81 &' >> %t.sh // RUN: echo 'TEST_81=$!' >> %t.sh // RUN: echo "wait $TEST_65" >> %t.sh #if defined(TEST_81) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_82 &' >> %t.sh // RUN: echo 'TEST_82=$!' >> %t.sh // RUN: echo "wait $TEST_66" >> %t.sh #if defined(TEST_82) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_83 &' >> %t.sh // RUN: echo 'TEST_83=$!' >> %t.sh // RUN: echo "wait $TEST_67" >> %t.sh -#if defined(TEST_83) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#include +#if defined(TEST_83) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_84 &' >> %t.sh // RUN: echo 'TEST_84=$!' >> %t.sh // RUN: echo "wait $TEST_68" >> %t.sh -#if defined(TEST_84) -#include +#if defined(TEST_84) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_85 &' >> %t.sh // RUN: echo 'TEST_85=$!' >> %t.sh // RUN: echo "wait $TEST_69" >> %t.sh -#if defined(TEST_85) && !defined(_LIBCPP_HAS_NO_THREADS) -#include +#if defined(TEST_85) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_86 &' >> %t.sh // RUN: echo 'TEST_86=$!' >> %t.sh // RUN: echo "wait $TEST_70" >> %t.sh -#if defined(TEST_86) -#include +#if defined(TEST_86) && !defined(_LIBCPP_HAS_NO_THREADS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_87 &' >> %t.sh // RUN: echo 'TEST_87=$!' >> %t.sh // RUN: echo "wait $TEST_71" >> %t.sh #if defined(TEST_87) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_88 &' >> %t.sh // RUN: echo 'TEST_88=$!' >> %t.sh // RUN: echo "wait $TEST_72" >> %t.sh -#if defined(TEST_88) && !defined(_LIBCPP_HAS_NO_THREADS) -#include +#if defined(TEST_88) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_89 &' >> %t.sh // RUN: echo 'TEST_89=$!' >> %t.sh // RUN: echo "wait $TEST_73" >> %t.sh -#if defined(TEST_89) -#include +#if defined(TEST_89) && !defined(_LIBCPP_HAS_NO_THREADS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_90 &' >> %t.sh // RUN: echo 'TEST_90=$!' >> %t.sh // RUN: echo "wait $TEST_74" >> %t.sh #if defined(TEST_90) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_91 &' >> %t.sh // RUN: echo 'TEST_91=$!' >> %t.sh // RUN: echo "wait $TEST_75" >> %t.sh -#if defined(TEST_91) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#include +#if defined(TEST_91) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_92 &' >> %t.sh // RUN: echo 'TEST_92=$!' >> %t.sh // RUN: echo "wait $TEST_76" >> %t.sh -#if defined(TEST_92) -#include +#if defined(TEST_92) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_93 &' >> %t.sh // RUN: echo 'TEST_93=$!' >> %t.sh // RUN: echo "wait $TEST_77" >> %t.sh -#if defined(TEST_93) && __cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS) -#include +#if defined(TEST_93) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_94 &' >> %t.sh // RUN: echo 'TEST_94=$!' >> %t.sh // RUN: echo "wait $TEST_78" >> %t.sh -#if defined(TEST_94) -#include +#if defined(TEST_94) && __cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_95 &' >> %t.sh // RUN: echo 'TEST_95=$!' >> %t.sh // RUN: echo "wait $TEST_79" >> %t.sh #if defined(TEST_95) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_96 &' >> %t.sh // RUN: echo 'TEST_96=$!' >> %t.sh // RUN: echo "wait $TEST_80" >> %t.sh #if defined(TEST_96) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_97 &' >> %t.sh // RUN: echo 'TEST_97=$!' >> %t.sh // RUN: echo "wait $TEST_81" >> %t.sh #if defined(TEST_97) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_98 &' >> %t.sh // RUN: echo 'TEST_98=$!' >> %t.sh // RUN: echo "wait $TEST_82" >> %t.sh #if defined(TEST_98) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_99 &' >> %t.sh // RUN: echo 'TEST_99=$!' >> %t.sh // RUN: echo "wait $TEST_83" >> %t.sh #if defined(TEST_99) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_100 &' >> %t.sh // RUN: echo 'TEST_100=$!' >> %t.sh // RUN: echo "wait $TEST_84" >> %t.sh -#if defined(TEST_100) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#include +#if defined(TEST_100) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_101 &' >> %t.sh // RUN: echo 'TEST_101=$!' >> %t.sh // RUN: echo "wait $TEST_85" >> %t.sh -#if defined(TEST_101) -#include +#if defined(TEST_101) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_102 &' >> %t.sh // RUN: echo 'TEST_102=$!' >> %t.sh // RUN: echo "wait $TEST_86" >> %t.sh #if defined(TEST_102) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_103 &' >> %t.sh // RUN: echo 'TEST_103=$!' >> %t.sh // RUN: echo "wait $TEST_87" >> %t.sh #if defined(TEST_103) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_104 &' >> %t.sh // RUN: echo 'TEST_104=$!' >> %t.sh // RUN: echo "wait $TEST_88" >> %t.sh -#if defined(TEST_104) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) -#include +#if defined(TEST_104) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_105 &' >> %t.sh // RUN: echo 'TEST_105=$!' >> %t.sh // RUN: echo "wait $TEST_89" >> %t.sh -#if defined(TEST_105) -#include +#if defined(TEST_105) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_106 &' >> %t.sh // RUN: echo 'TEST_106=$!' >> %t.sh // RUN: echo "wait $TEST_90" >> %t.sh #if defined(TEST_106) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_107 &' >> %t.sh // RUN: echo 'TEST_107=$!' >> %t.sh // RUN: echo "wait $TEST_91" >> %t.sh -#if defined(TEST_107) && !defined(_LIBCPP_HAS_NO_THREADS) -#include +#if defined(TEST_107) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_108 &' >> %t.sh // RUN: echo 'TEST_108=$!' >> %t.sh // RUN: echo "wait $TEST_92" >> %t.sh -#if defined(TEST_108) -#include +#if defined(TEST_108) && !defined(_LIBCPP_HAS_NO_THREADS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_109 &' >> %t.sh // RUN: echo 'TEST_109=$!' >> %t.sh // RUN: echo "wait $TEST_93" >> %t.sh #if defined(TEST_109) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_110 &' >> %t.sh // RUN: echo 'TEST_110=$!' >> %t.sh // RUN: echo "wait $TEST_94" >> %t.sh #if defined(TEST_110) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_111 &' >> %t.sh // RUN: echo 'TEST_111=$!' >> %t.sh // RUN: echo "wait $TEST_95" >> %t.sh #if defined(TEST_111) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_112 &' >> %t.sh // RUN: echo 'TEST_112=$!' >> %t.sh // RUN: echo "wait $TEST_96" >> %t.sh #if defined(TEST_112) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_113 &' >> %t.sh // RUN: echo 'TEST_113=$!' >> %t.sh // RUN: echo "wait $TEST_97" >> %t.sh #if defined(TEST_113) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_114 &' >> %t.sh // RUN: echo 'TEST_114=$!' >> %t.sh // RUN: echo "wait $TEST_98" >> %t.sh #if defined(TEST_114) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_115 &' >> %t.sh // RUN: echo 'TEST_115=$!' >> %t.sh // RUN: echo "wait $TEST_99" >> %t.sh #if defined(TEST_115) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_116 &' >> %t.sh // RUN: echo 'TEST_116=$!' >> %t.sh // RUN: echo "wait $TEST_100" >> %t.sh #if defined(TEST_116) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_117 &' >> %t.sh // RUN: echo 'TEST_117=$!' >> %t.sh // RUN: echo "wait $TEST_101" >> %t.sh #if defined(TEST_117) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_118 &' >> %t.sh // RUN: echo 'TEST_118=$!' >> %t.sh // RUN: echo "wait $TEST_102" >> %t.sh #if defined(TEST_118) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_119 &' >> %t.sh // RUN: echo 'TEST_119=$!' >> %t.sh // RUN: echo "wait $TEST_103" >> %t.sh #if defined(TEST_119) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_120 &' >> %t.sh // RUN: echo 'TEST_120=$!' >> %t.sh // RUN: echo "wait $TEST_104" >> %t.sh -#if defined(TEST_120) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -#include +#if defined(TEST_120) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_121 &' >> %t.sh // RUN: echo 'TEST_121=$!' >> %t.sh // RUN: echo "wait $TEST_105" >> %t.sh #if defined(TEST_121) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_122 &' >> %t.sh // RUN: echo 'TEST_122=$!' >> %t.sh // RUN: echo "wait $TEST_106" >> %t.sh -#if defined(TEST_122) && __cplusplus >= 201103L -#include +#if defined(TEST_122) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_123 &' >> %t.sh // RUN: echo 'TEST_123=$!' >> %t.sh // RUN: echo "wait $TEST_107" >> %t.sh #if defined(TEST_123) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_124 &' >> %t.sh // RUN: echo 'TEST_124=$!' >> %t.sh // RUN: echo "wait $TEST_108" >> %t.sh #if defined(TEST_124) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_125 &' >> %t.sh // RUN: echo 'TEST_125=$!' >> %t.sh // RUN: echo "wait $TEST_109" >> %t.sh #if defined(TEST_125) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_126 &' >> %t.sh // RUN: echo 'TEST_126=$!' >> %t.sh // RUN: echo "wait $TEST_110" >> %t.sh #if defined(TEST_126) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_127 &' >> %t.sh // RUN: echo 'TEST_127=$!' >> %t.sh // RUN: echo "wait $TEST_111" >> %t.sh #if defined(TEST_127) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_128 &' >> %t.sh // RUN: echo 'TEST_128=$!' >> %t.sh // RUN: echo "wait $TEST_112" >> %t.sh #if defined(TEST_128) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_129 &' >> %t.sh // RUN: echo 'TEST_129=$!' >> %t.sh // RUN: echo "wait $TEST_113" >> %t.sh -#if defined(TEST_129) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L -#include +#if defined(TEST_129) && __cplusplus >= 201103L +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_130 &' >> %t.sh // RUN: echo 'TEST_130=$!' >> %t.sh // RUN: echo "wait $TEST_114" >> %t.sh -#if defined(TEST_130) && __cplusplus >= 201103L -#include +#if defined(TEST_130) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_131 &' >> %t.sh // RUN: echo 'TEST_131=$!' >> %t.sh // RUN: echo "wait $TEST_115" >> %t.sh #if defined(TEST_131) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_132 &' >> %t.sh // RUN: echo 'TEST_132=$!' >> %t.sh // RUN: echo "wait $TEST_116" >> %t.sh #if defined(TEST_132) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_133 &' >> %t.sh // RUN: echo 'TEST_133=$!' >> %t.sh // RUN: echo "wait $TEST_117" >> %t.sh #if defined(TEST_133) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_134 &' >> %t.sh // RUN: echo 'TEST_134=$!' >> %t.sh // RUN: echo "wait $TEST_118" >> %t.sh #if defined(TEST_134) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_135 &' >> %t.sh // RUN: echo 'TEST_135=$!' >> %t.sh // RUN: echo "wait $TEST_119" >> %t.sh #if defined(TEST_135) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_136 &' >> %t.sh // RUN: echo 'TEST_136=$!' >> %t.sh // RUN: echo "wait $TEST_120" >> %t.sh #if defined(TEST_136) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_137 &' >> %t.sh // RUN: echo 'TEST_137=$!' >> %t.sh // RUN: echo "wait $TEST_121" >> %t.sh #if defined(TEST_137) && __cplusplus >= 201103L -#include +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_138 &' >> %t.sh // RUN: echo 'TEST_138=$!' >> %t.sh // RUN: echo "wait $TEST_122" >> %t.sh -#if defined(TEST_138) -#include +#if defined(TEST_138) && __cplusplus >= 201103L +#include #endif // RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_139 &' >> %t.sh // RUN: echo 'TEST_139=$!' >> %t.sh // RUN: echo "wait $TEST_123" >> %t.sh #if defined(TEST_139) -#include +#include #endif +// RUN: echo '%{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_140 &' >> %t.sh +// RUN: echo 'TEST_140=$!' >> %t.sh // RUN: echo "wait $TEST_124" >> %t.sh +#if defined(TEST_140) +#include +#endif // RUN: echo "wait $TEST_125" >> %t.sh // RUN: echo "wait $TEST_126" >> %t.sh // RUN: echo "wait $TEST_127" >> %t.sh @@ -899,5 +904,6 @@ // RUN: echo "wait $TEST_137" >> %t.sh // RUN: echo "wait $TEST_138" >> %t.sh // RUN: echo "wait $TEST_139" >> %t.sh +// RUN: echo "wait $TEST_140" >> %t.sh // RUN: bash %t.sh // GENERATED-MARKER Index: libcxx/test/libcxx/nasty_macros.compile.pass.cpp =================================================================== --- libcxx/test/libcxx/nasty_macros.compile.pass.cpp +++ libcxx/test/libcxx/nasty_macros.compile.pass.cpp @@ -264,6 +264,7 @@ #endif #include #include +#include #include #include #if !defined(_LIBCPP_HAS_NO_THREADS) Index: libcxx/test/libcxx/no_assert_include.compile.pass.cpp =================================================================== --- libcxx/test/libcxx/no_assert_include.compile.pass.cpp +++ libcxx/test/libcxx/no_assert_include.compile.pass.cpp @@ -137,6 +137,7 @@ #endif #include #include +#include #include #include #if !defined(_LIBCPP_HAS_NO_THREADS) Index: libcxx/test/libcxx/private_headers.verify.cpp =================================================================== --- libcxx/test/libcxx/private_headers.verify.cpp +++ libcxx/test/libcxx/private_headers.verify.cpp @@ -470,6 +470,7 @@ #include <__iterator/wrap_iter.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/wrap_iter.h'}} #include <__locale> // expected-error@*:* {{use of private header from outside its module: '__locale'}} #include <__mbstate_t.h> // expected-error@*:* {{use of private header from outside its module: '__mbstate_t.h'}} +#include <__mdspan/extents.h> // expected-error@*:* {{use of private header from outside its module: '__mdspan/extents.h'}} #include <__memory/addressof.h> // expected-error@*:* {{use of private header from outside its module: '__memory/addressof.h'}} #include <__memory/align.h> // expected-error@*:* {{use of private header from outside its module: '__memory/align.h'}} #include <__memory/aligned_alloc.h> // expected-error@*:* {{use of private header from outside its module: '__memory/aligned_alloc.h'}} Index: libcxx/test/libcxx/transitive_includes.sh.cpp =================================================================== --- libcxx/test/libcxx/transitive_includes.sh.cpp +++ libcxx/test/libcxx/transitive_includes.sh.cpp @@ -322,232 +322,236 @@ #if defined(TEST_69) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_71 2> %t/header.memory +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_71 2> %t/header.mdspan #if defined(TEST_71) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_72 2> %t/header.memory_resource +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_72 2> %t/header.memory #if defined(TEST_72) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_73 2> %t/header.mutex +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_73 2> %t/header.memory_resource #if defined(TEST_73) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_74 2> %t/header.new +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_74 2> %t/header.mutex #if defined(TEST_74) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_75 2> %t/header.numbers +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_75 2> %t/header.new #if defined(TEST_75) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_76 2> %t/header.numeric +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_76 2> %t/header.numbers #if defined(TEST_76) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_77 2> %t/header.optional +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_77 2> %t/header.numeric #if defined(TEST_77) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_78 2> %t/header.ostream +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_78 2> %t/header.optional #if defined(TEST_78) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_79 2> %t/header.queue +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_79 2> %t/header.ostream #if defined(TEST_79) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_80 2> %t/header.random +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_80 2> %t/header.queue #if defined(TEST_80) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_81 2> %t/header.ranges +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_81 2> %t/header.random #if defined(TEST_81) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_82 2> %t/header.ratio +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_82 2> %t/header.ranges #if defined(TEST_82) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_83 2> %t/header.regex +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_83 2> %t/header.ratio #if defined(TEST_83) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_84 2> %t/header.scoped_allocator +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_84 2> %t/header.regex #if defined(TEST_84) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_85 2> %t/header.semaphore +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_85 2> %t/header.scoped_allocator #if defined(TEST_85) -#include +#include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_86 2> %t/header.set +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_86 2> %t/header.semaphore #if defined(TEST_86) +#include +#endif +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_87 2> %t/header.set +#if defined(TEST_87) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_88 2> %t/header.shared_mutex -#if defined(TEST_88) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_89 2> %t/header.shared_mutex +#if defined(TEST_89) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_89 2> %t/header.source_location -#if defined(TEST_89) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_90 2> %t/header.source_location +#if defined(TEST_90) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_90 2> %t/header.span -#if defined(TEST_90) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_91 2> %t/header.span +#if defined(TEST_91) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_91 2> %t/header.sstream -#if defined(TEST_91) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_92 2> %t/header.sstream +#if defined(TEST_92) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_92 2> %t/header.stack -#if defined(TEST_92) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_93 2> %t/header.stack +#if defined(TEST_93) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_96 2> %t/header.stdexcept -#if defined(TEST_96) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_97 2> %t/header.stdexcept +#if defined(TEST_97) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_100 2> %t/header.streambuf -#if defined(TEST_100) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_101 2> %t/header.streambuf +#if defined(TEST_101) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_101 2> %t/header.string -#if defined(TEST_101) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_102 2> %t/header.string +#if defined(TEST_102) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_103 2> %t/header.string_view -#if defined(TEST_103) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_104 2> %t/header.string_view +#if defined(TEST_104) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_104 2> %t/header.strstream -#if defined(TEST_104) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_105 2> %t/header.strstream +#if defined(TEST_105) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_105 2> %t/header.system_error -#if defined(TEST_105) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_106 2> %t/header.system_error +#if defined(TEST_106) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_107 2> %t/header.thread -#if defined(TEST_107) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_108 2> %t/header.thread +#if defined(TEST_108) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_108 2> %t/header.tuple -#if defined(TEST_108) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_109 2> %t/header.tuple +#if defined(TEST_109) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_109 2> %t/header.type_traits -#if defined(TEST_109) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_110 2> %t/header.type_traits +#if defined(TEST_110) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_110 2> %t/header.typeindex -#if defined(TEST_110) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_111 2> %t/header.typeindex +#if defined(TEST_111) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_111 2> %t/header.typeinfo -#if defined(TEST_111) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_112 2> %t/header.typeinfo +#if defined(TEST_112) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_113 2> %t/header.unordered_map -#if defined(TEST_113) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_114 2> %t/header.unordered_map +#if defined(TEST_114) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_114 2> %t/header.unordered_set -#if defined(TEST_114) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_115 2> %t/header.unordered_set +#if defined(TEST_115) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_115 2> %t/header.utility -#if defined(TEST_115) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_116 2> %t/header.utility +#if defined(TEST_116) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_116 2> %t/header.valarray -#if defined(TEST_116) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_117 2> %t/header.valarray +#if defined(TEST_117) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_117 2> %t/header.variant -#if defined(TEST_117) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_118 2> %t/header.variant +#if defined(TEST_118) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_118 2> %t/header.vector -#if defined(TEST_118) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_119 2> %t/header.vector +#if defined(TEST_119) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_119 2> %t/header.version -#if defined(TEST_119) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_120 2> %t/header.version +#if defined(TEST_120) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_122 2> %t/header.experimental_deque -#if defined(TEST_122) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_123 2> %t/header.experimental_deque +#if defined(TEST_123) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_123 2> %t/header.experimental_forward_list -#if defined(TEST_123) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_124 2> %t/header.experimental_forward_list +#if defined(TEST_124) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_124 2> %t/header.experimental_iterator -#if defined(TEST_124) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_125 2> %t/header.experimental_iterator +#if defined(TEST_125) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_125 2> %t/header.experimental_list -#if defined(TEST_125) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_126 2> %t/header.experimental_list +#if defined(TEST_126) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_126 2> %t/header.experimental_map -#if defined(TEST_126) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_127 2> %t/header.experimental_map +#if defined(TEST_127) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_127 2> %t/header.experimental_memory_resource -#if defined(TEST_127) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_128 2> %t/header.experimental_memory_resource +#if defined(TEST_128) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_128 2> %t/header.experimental_propagate_const -#if defined(TEST_128) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_129 2> %t/header.experimental_propagate_const +#if defined(TEST_129) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_129 2> %t/header.experimental_regex -#if defined(TEST_129) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_130 2> %t/header.experimental_regex +#if defined(TEST_130) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_130 2> %t/header.experimental_set -#if defined(TEST_130) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_131 2> %t/header.experimental_set +#if defined(TEST_131) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_131 2> %t/header.experimental_simd -#if defined(TEST_131) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_132 2> %t/header.experimental_simd +#if defined(TEST_132) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_132 2> %t/header.experimental_string -#if defined(TEST_132) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_133 2> %t/header.experimental_string +#if defined(TEST_133) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_133 2> %t/header.experimental_type_traits -#if defined(TEST_133) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_134 2> %t/header.experimental_type_traits +#if defined(TEST_134) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_134 2> %t/header.experimental_unordered_map -#if defined(TEST_134) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_135 2> %t/header.experimental_unordered_map +#if defined(TEST_135) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_135 2> %t/header.experimental_unordered_set -#if defined(TEST_135) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_136 2> %t/header.experimental_unordered_set +#if defined(TEST_136) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_136 2> %t/header.experimental_utility -#if defined(TEST_136) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_137 2> %t/header.experimental_utility +#if defined(TEST_137) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_137 2> %t/header.experimental_vector -#if defined(TEST_137) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_138 2> %t/header.experimental_vector +#if defined(TEST_138) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_138 2> %t/header.ext_hash_map -#if defined(TEST_138) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_139 2> %t/header.ext_hash_map +#if defined(TEST_139) #include #endif -// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_139 2> %t/header.ext_hash_set -#if defined(TEST_139) +// RUN: %{cxx} %s %{flags} %{compile_flags} --trace-includes -fshow-skipped-includes --preprocess -DTEST_140 2> %t/header.ext_hash_set +#if defined(TEST_140) #include #endif // RUN: %{python} %S/transitive_includes_to_csv.py %t > %t/transitive_includes.csv Index: libcxx/test/std/containers/views/mdspan/extents/ConvertibleToIntegral.h =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/ConvertibleToIntegral.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef CONVERTIBLE_TO_INTEGRAL_H +#define CONVERTIBLE_TO_INTEGRAL_H + +struct IntType { + int val; + constexpr IntType() = default; + constexpr IntType(int v) noexcept : val(v){}; + + constexpr bool operator==(const IntType& rhs) const { return val == rhs.val; } + constexpr operator int() const noexcept { return val; } + constexpr operator unsigned char() const noexcept { return val; } +}; + +#endif Index: libcxx/test/std/containers/views/mdspan/extents/assert.cons.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/assert.cons.pass.cpp @@ -0,0 +1,61 @@ +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// XFAIL: availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 + +// + +// template +// constexpr explicit extents(OtherIndexTypes...) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - (is_convertible_v && ...) is true, +// - (is_nothrow_constructible_v && ...) is true, and +// - N == rank_dynamic() || N == rank() is true. +// +// +// template +// constexpr explicit(N != rank_dynamic()) extents(span) noexcept; +// template +// constexpr explicit(N != rank_dynamic()) extents(const array&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - is_convertible_v is true, +// - is_nothrow_constructible_v is true, and +// - N == rank_dynamic() || N == rank() is true. +// + +#include +#include +#include +#include + +#include "check_assertion.h" + +int main() { + constexpr size_t D = std::dynamic_extent; + { + std::extents e1(3, 5); // should work + (void)e1; + } + + TEST_LIBCPP_ASSERT_FAILURE(([] { std::extents e1(3, 3); }()), + "extents construction: mismatch of provided arguments with static extents."); + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + std::extents e1(std::array{3, 3}); + }()), + "extents construction: mismatch of provided arguments with static extents."); + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + std::array a{3, 3}; + std::span s(a); + std::extents e1(s); + }()), + "extents construction: mismatch of provided arguments with static extents."); +} Index: libcxx/test/std/containers/views/mdspan/extents/comparison.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/comparison.pass.cpp @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// friend constexpr bool operator==(const extents&, +// const extents&) noexcept; +// ` + +#include +#include +#include +#include + +#include "test_macros.h" + +template +void test_comparison(bool equal, To dest, From src) { + assert((dest == src) == equal); + assert((dest != src) != equal); +} + +template +void test_comparison_different_rank() { + constexpr size_t D = std::dynamic_extent; + + test_comparison(false, std::extents(), std::extents(1)); + test_comparison(false, std::extents(), std::extents()); + + test_comparison(false, std::extents(1), std::extents()); + test_comparison(false, std::extents(), std::extents()); + + test_comparison(false, std::extents(5), std::extents(5, 5)); + test_comparison(false, std::extents(), std::extents(5)); + test_comparison(false, std::extents(), std::extents()); + + test_comparison(false, std::extents(5, 5), std::extents(5)); + test_comparison(false, std::extents(5), std::extents(5)); + test_comparison(false, std::extents(), std::extents()); +} + +template +void test_comparison_same_rank() { + constexpr size_t D = std::dynamic_extent; + + test_comparison(true, std::extents(), std::extents()); + + test_comparison(true, std::extents(5), std::extents(5)); + test_comparison(true, std::extents(), std::extents(5)); + test_comparison(true, std::extents(5), std::extents()); + test_comparison(true, std::extents(), std::extents< T2, 5>()); + test_comparison(false, std::extents(5), std::extents(7)); + test_comparison(false, std::extents(), std::extents(7)); + test_comparison(false, std::extents(5), std::extents()); + test_comparison(false, std::extents(), std::extents()); + + test_comparison(true, std::extents(5, 6, 7, 8, 9), std::extents(5, 6, 7, 8, 9)); + test_comparison(true, std::extents(5, 7, 9), std::extents(6, 7)); + test_comparison(true, std::extents(5, 6, 7, 8, 9), std::extents()); + test_comparison( + false, std::extents(5, 6, 7, 8, 9), std::extents(5, 6, 3, 8, 9)); + test_comparison(false, std::extents(5, 7, 9), std::extents(6, 7)); + test_comparison(false, std::extents(5, 6, 7, 8, 9), std::extents()); +} + +template +void test_comparison() { + test_comparison_same_rank(); + test_comparison_different_rank(); +} + +int main() { + test_comparison(); + test_comparison(); + test_comparison(); + test_comparison(); +} Index: libcxx/test/std/containers/views/mdspan/extents/cons.fail.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/cons.fail.cpp @@ -0,0 +1,111 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// constexpr extents() noexcept; +// +// +// template +// constexpr explicit extents(OtherIndexTypes...) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - (is_convertible_v && ...) is true, +// - (is_nothrow_constructible_v && ...) is true, and +// - N == rank_dynamic() || N == rank() is true. +// +// +// template +// constexpr explicit(N != rank_dynamic()) extents(span) noexcept; +// template +// constexpr explicit(N != rank_dynamic()) extents(const array&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - is_convertible_v is true, +// - is_nothrow_constructible_v is true, and +// - N == rank_dynamic() || N == rank() is true. +// + +#include +#include +#include +#include + +#include "ConvertibleToIntegral.h" +#include "test_macros.h" + +template +void implicit_construction(E) {} + +template +void test() { + constexpr size_t D = std::dynamic_extent; + + // clang-format off + // test less than rank_dynammic args + { + std::array a1{3}; + std::span s1(a1.data(), 1); + std::extents e1(2); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e2(a1); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e3(s1); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void)e1; + (void)e2; + (void)e3; + } + // test more than rank_dynammic but less than rank args + { + std::array a3{3, 4, 5}; + std::span s3(a3.data(), 3); + std::extents e1(3, 4, 5); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e2(a3); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e3(s3); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void)e1; + (void)e2; + (void)e3; + } + // test more than rank args + { + std::array a5{3, 4, 5, 6, 7}; + std::span s5(a5.data(), 5); + std::extents e1(3, 4, 5, 6, 7); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e2(a5); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e3(s5); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void)e1; + (void)e2; + (void)e3; + } + + // test implicit construction fails from span and array if all extents are given + { + std::array a5{3, 4, 5, 6, 7}; + std::span s5(a5.data(), 5); + // check that explicit construction works, i.e. no error + std::extents e1(a5); + std::extents e2(s5); + (void)e1; + (void)e2; + implicit_construction>(a5); // expected-error {{no matching function for call to 'implicit_construction'}} + implicit_construction>(s5); // expected-error {{no matching function for call to 'implicit_construction'}} + } + // test construction fails from types not convertible to index_type but convertible to other integer types + { + std::array a{IntType(3)}; + std::span s{a}; + std::extents e1(IntType(3)); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e2(a); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents e3(s); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void)e1; + (void)e2; + (void)e3; + } + // clang-format on +} + +int main() { test(); } Index: libcxx/test/std/containers/views/mdspan/extents/cons.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/cons.pass.cpp @@ -0,0 +1,136 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// constexpr extents() noexcept; +// +// +// template +// constexpr explicit extents(OtherIndexTypes...) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - (is_convertible_v && ...) is true, +// - (is_nothrow_constructible_v && ...) is true, and +// - N == rank_dynamic() || N == rank() is true. +// +// +// template +// constexpr explicit(N != rank_dynamic()) extents(span) noexcept; +// template +// constexpr explicit(N != rank_dynamic()) extents(const array&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - is_convertible_v is true, +// - is_nothrow_constructible_v is true, and +// - N == rank_dynamic() || N == rank() is true. +// + +#include +#include +#include +#include + +#include "ConvertibleToIntegral.h" +#include "test_macros.h" + +// std::extents can be constructed from just indices, a std::array, or a std::span +// In each of those cases one can either provide all extents, or just the dynamic ones +// If constructed from std::span, the span needs to have a static extent +// Furthermore, the indices/array/span can have integer types other than index_type + +template +void test_runtime_observers(E ext, AllExtents expected) { + for (typename E::rank_type r = 0; r < ext.rank(); r++) { + ASSERT_SAME_TYPE(decltype(ext.extent(0)), typename E::index_type); + assert(ext.extent(r) == static_cast(expected[r])); + } +} + +template +void test_implicit_construction_call(E e, AllExtents all_ext) { + test_runtime_observers(e, all_ext); +} + +template +void test_implicit_construction(AllExtents all_ext, Extents ext) { + test_implicit_construction_call(ext, all_ext); + test_implicit_construction_call( + std::span(ext.data(), ext.size()), all_ext); +} + +template +void test_construction(AllExtents all_ext, Extents ext, std::index_sequence) { + // construction from indices + test_runtime_observers(E(ext[Indices]...), all_ext); + // construction from array + test_runtime_observers(E(ext), all_ext); + // construction from span + test_runtime_observers( + E(std::span(ext.data(), sizeof...(Indices))), all_ext); +} + +template +void test_construction(AllExtents all_ext) { + // test construction from all extents + test_construction(all_ext, all_ext, std::make_index_sequence()); + + // test construction from just dynamic extents + // create an array of just the extents corresponding to dynamic values + std::array dyn_ext; + size_t dynamic_idx = 0; + for (size_t r = 0; r < E::rank(); r++) { + if (E::static_extent(r) == std::dynamic_extent) { + dyn_ext[dynamic_idx] = all_ext[r]; + dynamic_idx++; + } + } + test_construction(all_ext, dyn_ext, std::make_index_sequence()); + test_implicit_construction(all_ext, dyn_ext); +} + +template +void test() { + constexpr size_t D = std::dynamic_extent; + + test_construction>(std::array{}); + + test_construction>(std::array{3}); + test_construction>(std::array{3}); + + test_construction>(std::array{3, 7}); + test_construction>(std::array{3, 7}); + test_construction>(std::array{3, 7}); + test_construction>(std::array{3, 7}); + + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + test_construction>(std::array{3, 7, 9}); + + test_construction>(std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}); + test_construction>(std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}); + test_construction>(std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}); +} + +int main() { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} Index: libcxx/test/std/containers/views/mdspan/extents/constexpr_usage.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/constexpr_usage.pass.cpp @@ -0,0 +1,160 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// constexpr extents() noexcept; +// +// +// template +// constexpr explicit extents(OtherIndexTypes...) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - (is_convertible_v && ...) is true, +// - (is_nothrow_constructible_v && ...) is true, and +// - N == rank_dynamic() || N == rank() is true. +// +// +// template +// constexpr explicit(N != rank_dynamic()) extents(span) noexcept; +// template +// constexpr explicit(N != rank_dynamic()) extents(const array&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - is_convertible_v is true, +// - is_nothrow_constructible_v is true, and +// - N == rank_dynamic() || N == rank() is true. +// + +#include +#include +#include +#include +#include +#include + +#include "ConvertibleToIntegral.h" +#include "test_macros.h" + +// std::extents can be constructed from just indices, a std::array, or a std::span +// In each of those cases one can either provide all extents, or just the dynamic ones +// If constructed from std::span, the span needs to have a static extent +// Furthermore, the indices/array/span can have integer types other than index_type + +// All of this should work in constant expressions + +// This tests the actual observers and returns the sum of extents + rank +template +constexpr size_t test_runtime_observers(E ext, AllExtents expected) { + size_t result = 0; + for (typename E::rank_type r = 0; r < ext.rank(); r++) { + result += ext.extent(r) == static_cast(expected[r]); + result += ext.extent(r); + } + return result; +} + +// Make sure constexpr usage of extents works in implicit construction +template +constexpr size_t test_implicit_construction_call(E e, AllExtents all_ext) { + return test_runtime_observers(e, all_ext); +} + +template +constexpr size_t test_implicit_construction(AllExtents all_ext, Extents ext) { + return test_implicit_construction_call(ext, all_ext) + + test_implicit_construction_call( + std::span(ext.data(), ext.size()), all_ext); +} + +template +constexpr size_t test_construction(AllExtents all_ext, Extents ext, std::index_sequence) { + size_t result = 0; + // construction from indicies + result += test_runtime_observers(E(ext[Indices]...), all_ext); + // construction from array + result += test_runtime_observers(E(ext), all_ext); + // construction from span + result += test_runtime_observers( + E(std::span(ext.data(), sizeof...(Indices))), all_ext); + return result; +} + +template +constexpr size_t test_construction(AllExtents all_ext) { + size_t result = 0; + // test construction from all extents + result += test_construction(all_ext, all_ext, std::make_index_sequence()); + + // test construction from just dynamic extents + // create an array of just the extents corresponding to dynamic values + std::array dyn_ext{0}; + size_t dynamic_idx = 0; + for (size_t r = 0; r < E::rank(); r++) { + if (E::static_extent(r) == std::dynamic_extent) { + dyn_ext[dynamic_idx] = all_ext[r]; + dynamic_idx++; + } + } + result += test_construction(all_ext, dyn_ext, std::make_index_sequence()); + result += test_implicit_construction(all_ext, dyn_ext); + return result; +} + +template +struct const_expr { + // num_tests is how many different construction scenarios each + // construction tests expands to in the end. + // expected is the value each individual test return + constexpr static size_t num_tests = 8; + constexpr static bool value = result == num_tests * expected; +}; + +template +void test() { + constexpr size_t D = std::dynamic_extent; + + static_assert(const_expr>(std::array{}), 0>::value); + + static_assert(const_expr>(std::array{3}), 3 + 1>::value); + + static_assert(const_expr>(std::array{3}), 3 + 1>::value); + + static_assert(const_expr>(std::array{3, 7}), 10 + 2>::value); + static_assert(const_expr>(std::array{3, 7}), 10 + 2>::value); + static_assert(const_expr>(std::array{3, 7}), 10 + 2>::value); + static_assert(const_expr>(std::array{3, 7}), 10 + 2>::value); + + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + static_assert(const_expr>(std::array{3, 7, 9}), 19 + 3>::value); + + static_assert(const_expr>( + std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}), + 45 + 9>::value); + static_assert(const_expr>( + std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}), + 45 + 9>::value); + static_assert(const_expr>( + std::array{1, 2, 3, 4, 5, 6, 7, 8, 9}), + 45 + 9>::value); +} + +int main() { + test(); + test(); + test(); + test(); + test(); +} Index: libcxx/test/std/containers/views/mdspan/extents/conversion.fail.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/conversion.fail.cpp @@ -0,0 +1,100 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// constexpr explicit(see below) extents(const extents&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - sizeof...(OtherExtents) == rank() is true, and +// - ((OtherExtents == dynamic_extent || Extents == dynamic_extent || OtherExtents == Extents) && ...) is true. +// + +#include +#include +#include +#include + +#include "test_macros.h" + +// std::extents can be converted into each other as long as there aren't any +// mismatched static extents. +// Convertibility requires that no runtime dimension is assigned to a static dimension, +// and that the destinations index_type has a larger or equal max value than the +// sources index_type + +// clang-format off +void test_no_implicit_conversion() { + constexpr size_t D = std::dynamic_extent; + { + std::extents from; + std::extents to; + to = from; // expected-error {{no viable overloaded '='}} + } + { + std::extents from; + std::extents to; + to = from; // expected-error {{no viable overloaded '='}} + } + { + std::extents from; + std::extents to; + to = from; // expected-error {{no viable overloaded '='}} + } + { + std::extents from; + std::extents to; + to = from; // expected-error {{no viable overloaded '='}} + } +} + +void test_rank_mismatch() { + constexpr size_t D = std::dynamic_extent; + { + std::extents from; + std::extents to(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void) to; + } + { + std::extents from; + std::extents to0(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents to1(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + std::extents to3(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void) to0; + (void) to1; + (void) to3; + } +} + +void test_static_extent_mismatch() { + constexpr size_t D = std::dynamic_extent; + { + std::extents from; + std::extents to(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void) to; + } + { + std::extents from; + std::extents to(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void) to; + } + { + std::extents from; + std::extents to(from); // expected-error {{no matching constructor for initialization of 'std::extents'}} + (void) to; + } +} +// clang-format on + +int main() { + test_rank_mismatch(); + test_static_extent_mismatch(); + test_no_implicit_conversion(); +} Index: libcxx/test/std/containers/views/mdspan/extents/conversion.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/conversion.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// constexpr explicit(see below) extents(const extents&) noexcept; +// +// Remarks: These constructors shall not participate in overload resolution unless: +// - sizeof...(OtherExtents) == rank() is true, and +// - ((OtherExtents == dynamic_extent || Extents == dynamic_extent || OtherExtents == Extents) && ...) is true. +// + +#include +#include +#include +#include + +#include "test_macros.h" + +// std::extents can be converted into each other as long as there aren't any +// mismatched static extents. +// Convertibility requires that no runtime dimension is assigned to a static dimension, +// and that the destinations index_type has a larger or equal max value than the +// sources index_type + +template +void test_implicit_conversion(To dest, From src) { + assert(dest == src); +} + +template +void test_conversion(From src) { + To dest(src); + assert(dest == src); + if constexpr (implicit) { + dest = src; + assert(dest == src); + test_implicit_conversion(src, src); + } +} + +template +void test_conversion() { + constexpr size_t D = std::dynamic_extent; + constexpr bool idx_convertible = + static_cast(std::numeric_limits::max()) >= static_cast(std::numeric_limits::max()); + + // clang-format off + test_conversion>(std::extents()); + test_conversion>(std::extents(5)); + test_conversion>(std::extents(5)); + test_conversion>(std::extents()); + test_conversion>(std::extents(5, 5)); + test_conversion>(std::extents(5, 5)); + test_conversion>(std::extents(5)); + test_conversion>(std::extents()); + test_conversion>(std::extents(5, 7)); + test_conversion>( + std::extents(5, 7, 8, 9, 1)); + test_conversion>(std::extents(5)); + test_conversion>(std::extents()); + // clang-format on +} + +int main() { + test_conversion(); + test_conversion(); + test_conversion(); + test_conversion(); +} Index: libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// explicit extents(Integrals...) -> see below; +// Constraints: (is_convertible_v && ...) is true. +// +// Remarks: The deduced type is dextents. + +#include +#include + +#include "ConvertibleToIntegral.h" +#include "test_macros.h" + +template +void test(E e, Expected expected) { + ASSERT_SAME_TYPE(E, Expected); + assert(e == expected); +} + +int main() { + constexpr size_t D = std::dynamic_extent; + + test(std::extents(), std::extents()); + test(std::extents(1), std::extents(1)); + test(std::extents(1, 2u), std::extents(1, 2u)); + test(std::extents(1, 2u, 3, 4, 5, 6, 7, 8, 9), + std::extents(1, 2u, 3, 4, 5, 6, 7, 8, 9)); +} Index: libcxx/test/std/containers/views/mdspan/extents/dextents.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/dextents.pass.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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// using dextents = see below; +// +// Result: A type E that is a specialization of extents such that E::rank() == Rank && E::rank() == E::rank_dynamic() is true, and E::index_type denotes IndexType. + +#include +#include + +#include "test_macros.h" + +template +void test_alias_template_dextents() { + constexpr size_t D = std::dynamic_extent; + ASSERT_SAME_TYPE(std::dextents, std::extents); + ASSERT_SAME_TYPE(std::dextents, std::extents); + ASSERT_SAME_TYPE(std::dextents, std::extents); + ASSERT_SAME_TYPE(std::dextents, std::extents); + ASSERT_SAME_TYPE(std::dextents, std::extents); +} + +int main() { + test_alias_template_dextents(); + test_alias_template_dextents(); + test_alias_template_dextents(); +} Index: libcxx/test/std/containers/views/mdspan/extents/obs_static.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/obs_static.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// static constexpr rank_type rank() noexcept; +// static constexpr rank_type rank_dynamic() noexcept; +// static constexpr size_t static_extent(rank_type) noexcept; +// constexpr index_type extent(rank_type) const noexcept; +// + +#include +#include +#include + +#include "test_macros.h" + +template +void test_static_observers(std::index_sequence, std::index_sequence) { + ASSERT_NOEXCEPT(E::rank()); + static_assert(E::rank() == rank); + ASSERT_NOEXCEPT(E::rank_dynamic()); + static_assert(E::rank_dynamic() == rank_dynamic); + + // Let's only test this if the call isn't a precondition violation + if constexpr (rank > 0) { + ASSERT_NOEXCEPT(E::static_extent(0)); + ASSERT_SAME_TYPE(decltype(E::static_extent(0)), size_t); + static_assert(((E::static_extent(Indices) == StaticExts) && ...)); + } +} + +template +void test_static_observers() { + test_static_observers( + std::index_sequence(), std::make_index_sequence()); +} + +template +void test() { + constexpr size_t D = std::dynamic_extent; + constexpr size_t S = 5; + + test_static_observers, 0, 0>(); + + test_static_observers, 1, 0, S>(); + test_static_observers, 1, 1, D>(); + + test_static_observers, 2, 0, S, S>(); + test_static_observers, 2, 1, S, D>(); + test_static_observers, 2, 1, D, S>(); + test_static_observers, 2, 2, D, D>(); + + test_static_observers, 3, 0, S, S, S>(); + test_static_observers, 3, 1, S, S, D>(); + test_static_observers, 3, 1, S, D, S>(); + test_static_observers, 3, 1, D, S, S>(); + test_static_observers, 3, 2, S, D, D>(); + test_static_observers, 3, 2, D, S, D>(); + test_static_observers, 3, 2, D, D, S>(); + test_static_observers, 3, 3, D, D, D>(); +} + +int main() { + test(); + test(); + test(); + test(); + test(); +} Index: libcxx/test/std/containers/views/mdspan/extents/types.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/containers/views/mdspan/extents/types.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// class extents { +// public: +// // types +// using index_type = IndexType; +// using size_type = make_unsigned_t; +// using rank_type = size_t; +// + +#include +#include +#include +#include + +#include "test_macros.h" + +template +void testExtents() { + ASSERT_SAME_TYPE(typename E::index_type, IndexType); + ASSERT_SAME_TYPE(typename E::size_type, std::make_unsigned_t); + ASSERT_SAME_TYPE(typename E::rank_type, size_t); + + static_assert(sizeof...(Extents) == E::rank()); + static_assert((static_cast(Extents == std::dynamic_extent) + ...) == E::rank_dynamic()); + + static_assert(std::regular); + static_assert(std::is_trivially_copyable_v); +} + +template +void testExtents() { + testExtents, IndexType, Extents...>(); +} + +template +void test() { + constexpr size_t D = std::dynamic_extent; + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + testExtents(); + + testExtents(); + testExtents(); + testExtents(); +} + +int main() { + test(); + test(); + test(); + test(); + test(); +}