From: Jonathan Wakely Date: Sat, 11 Feb 2023 00:24:47 +0000 (+0000) Subject: libstdc++: Fix non-reserved names in PSTL headers X-Git-Tag: basepoints/gcc-14~1129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb6beb887e64935c12a3508ead6d1806ef341ba2;p=thirdparty%2Fgcc.git libstdc++: Fix non-reserved names in PSTL headers libstdc++-v3/ChangeLog: * include/pstl/algorithm_fwd.h (__pattern_search_n) (__brick_unique_copy, __brick_adjacent_find) (__brick_generate_n, __pattern_generate_n): Use reserved names for parameters. * include/pstl/algorithm_impl.h (__brick_unique_copy) (__pattern_reverse, __brick_generate_n): Likewise. * include/pstl/execution_impl.h (__prefer_unsequenced_tag) (__prefer_parallel_tag): Likewise. * include/pstl/glue_algorithm_impl.h (transform): Likewise. * include/pstl/glue_numeric_defs.h (adjacent_difference): Likewise. * include/pstl/numeric_impl.h (__brick_adjacent_difference): Likewise. * include/pstl/parallel_backend_tbb.h (__merge_func): Likewise. * include/pstl/unseq_backend_simd.h (_Combiner) (__simd_min_element, __simd_minmax_element): Likewise. * testsuite/17_intro/names_pstl.cc: New test. --- diff --git a/libstdc++-v3/include/pstl/algorithm_fwd.h b/libstdc++-v3/include/pstl/algorithm_fwd.h index 814356b38fb7..e85125c4dc70 100644 --- a/libstdc++-v3/include/pstl/algorithm_fwd.h +++ b/libstdc++-v3/include/pstl/algorithm_fwd.h @@ -364,17 +364,17 @@ __brick_search_n(_ForwardIterator, _ForwardIterator, _Size, const _Tp&, _BinaryP /*vector=*/std::true_type) noexcept; template + class _IsVector> _ForwardIterator __pattern_search_n(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Size, const _Tp&, _BinaryPredicate, - IsVector, + _IsVector, /*is_parallel=*/std::false_type) noexcept; template + class _IsVector> _RandomAccessIterator __pattern_search_n(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Size, const _Tp&, - _BinaryPredicate, IsVector, + _BinaryPredicate, _IsVector, /*is_parallel=*/std::true_type) noexcept; //------------------------------------------------------------------------ @@ -528,8 +528,8 @@ __pattern_unique(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Binary // unique_copy //------------------------------------------------------------------------ -template -OutputIterator __brick_unique_copy(_ForwardIterator, _ForwardIterator, OutputIterator, _BinaryPredicate, +template + _OutputIterator __brick_unique_copy(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryPredicate, /*vector=*/std::false_type) noexcept; template @@ -823,12 +823,12 @@ __pattern_partial_sort_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterat template _ForwardIterator __brick_adjacent_find(_ForwardIterator, _ForwardIterator, _BinaryPredicate, - /* IsVector = */ std::true_type, bool) noexcept; + /* _IsVector = */ std::true_type, bool) noexcept; template _ForwardIterator __brick_adjacent_find(_ForwardIterator, _ForwardIterator, _BinaryPredicate, - /* IsVector = */ std::false_type, bool) noexcept; + /* _IsVector = */ std::false_type, bool) noexcept; template _ForwardIterator @@ -920,22 +920,22 @@ _ForwardIterator __pattern_generate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Generator, /*is_parallel=*/std::true_type, _IsVector); -template -OutputIterator __brick_generate_n(OutputIterator, Size, _Generator, +template + _OutputIterator __brick_generate_n(_OutputIterator, _Size, _Generator, /* is_vector = */ std::true_type) noexcept; -template -OutputIterator __brick_generate_n(OutputIterator, Size, _Generator, +template + _OutputIterator __brick_generate_n(_OutputIterator, _Size, _Generator, /* is_vector = */ std::false_type) noexcept; -template -OutputIterator -__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator, +template + _OutputIterator +__pattern_generate_n(_ExecutionPolicy&&, _OutputIterator, _Size, _Generator, /*is_parallel=*/std::false_type, _IsVector) noexcept; -template -OutputIterator -__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator, +template + _OutputIterator +__pattern_generate_n(_ExecutionPolicy&&, _OutputIterator, _Size, _Generator, /*is_parallel=*/std::true_type, _IsVector); //------------------------------------------------------------------------ diff --git a/libstdc++-v3/include/pstl/algorithm_impl.h b/libstdc++-v3/include/pstl/algorithm_impl.h index 8e127b5ba224..32c19990ed0f 100644 --- a/libstdc++-v3/include/pstl/algorithm_impl.h +++ b/libstdc++-v3/include/pstl/algorithm_impl.h @@ -1293,17 +1293,17 @@ __pattern_unique(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt // unique_copy //------------------------------------------------------------------------ -template -OutputIterator -__brick_unique_copy(_ForwardIterator __first, _ForwardIterator __last, OutputIterator __result, _BinaryPredicate __pred, +template + _OutputIterator +__brick_unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred, /*vector=*/std::false_type) noexcept { return std::unique_copy(__first, __last, __result, __pred); } -template -OutputIterator -__brick_unique_copy(_RandomAccessIterator __first, _RandomAccessIterator __last, OutputIterator __result, +template + _OutputIterator +__brick_unique_copy(_RandomAccessIterator __first, _RandomAccessIterator __last, _OutputIterator __result, _BinaryPredicate __pred, /*vector=*/std::true_type) noexcept { #if (_PSTL_MONOTONIC_PRESENT) @@ -1449,10 +1449,10 @@ __brick_reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, _ template void __pattern_reverse(_ExecutionPolicy&&, _BidirectionalIterator __first, _BidirectionalIterator __last, - _IsVector _is_vector, + _IsVector __is_vector, /*is_parallel=*/std::false_type) noexcept { - __internal::__brick_reverse(__first, __last, _is_vector); + __internal::__brick_reverse(__first, __last, __is_vector); } template @@ -2514,16 +2514,16 @@ __pattern_generate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forward }); } -template -OutputIterator -__brick_generate_n(OutputIterator __first, Size __count, _Generator __g, /* is_vector = */ std::true_type) noexcept +template + _OutputIterator +__brick_generate_n(_OutputIterator __first, _Size __count, _Generator __g, /* is_vector = */ std::true_type) noexcept { return __unseq_backend::__simd_generate_n(__first, __count, __g); } -template -OutputIterator -__brick_generate_n(OutputIterator __first, Size __count, _Generator __g, /* is_vector = */ std::false_type) noexcept +template + _OutputIterator +__brick_generate_n(_OutputIterator __first, _Size __count, _Generator __g, /* is_vector = */ std::false_type) noexcept { return std::generate_n(__first, __count, __g); } diff --git a/libstdc++-v3/include/pstl/execution_impl.h b/libstdc++-v3/include/pstl/execution_impl.h index 53ff11fca46e..e0969a1db9c1 100644 --- a/libstdc++-v3/include/pstl/execution_impl.h +++ b/libstdc++-v3/include/pstl/execution_impl.h @@ -139,18 +139,18 @@ __is_parallelization_preferred(_ExecutionPolicy&& __exec) typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()); } -template +template struct __prefer_unsequenced_tag { - static constexpr bool value = __internal::__allow_unsequenced::value && + static constexpr bool value = __internal::__allow_unsequenced<__policy>::value && __internal::__is_random_access_iterator<_IteratorTypes...>::value; typedef std::integral_constant type; }; -template +template struct __prefer_parallel_tag { - static constexpr bool value = __internal::__allow_parallel::value && + static constexpr bool value = __internal::__allow_parallel<__policy>::value && __internal::__is_random_access_iterator<_IteratorTypes...>::value; typedef std::integral_constant type; }; diff --git a/libstdc++-v3/include/pstl/glue_algorithm_impl.h b/libstdc++-v3/include/pstl/glue_algorithm_impl.h index d2e30529f785..b16306f2e990 100644 --- a/libstdc++-v3/include/pstl/glue_algorithm_impl.h +++ b/libstdc++-v3/include/pstl/glue_algorithm_impl.h @@ -340,7 +340,7 @@ transform(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterato typedef typename iterator_traits<_ForwardIterator>::reference _OutputType; return __pstl::__internal::__pattern_walk3( std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __result, - [__op](_Input1Type x, _Input2Type y, _OutputType z) mutable { z = __op(x, y); }, + [__op](_Input1Type __x, _Input2Type __y, _OutputType __z) mutable { __z = __op(__x, __y); }, __pstl::__internal::__is_vectorization_preferred<_ExecutionPolicy, _ForwardIterator1, _ForwardIterator2, _ForwardIterator>(__exec), __pstl::__internal::__is_parallelization_preferred<_ExecutionPolicy, _ForwardIterator1, _ForwardIterator2, diff --git a/libstdc++-v3/include/pstl/glue_numeric_defs.h b/libstdc++-v3/include/pstl/glue_numeric_defs.h index 78df17030793..9029a05f0ddd 100644 --- a/libstdc++-v3/include/pstl/glue_numeric_defs.h +++ b/libstdc++-v3/include/pstl/glue_numeric_defs.h @@ -105,7 +105,7 @@ transform_inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ template __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, - _ForwardIterator2 __d_first, _BinaryOperation op); + _ForwardIterator2 __d_first, _BinaryOperation __op); template __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> diff --git a/libstdc++-v3/include/pstl/numeric_impl.h b/libstdc++-v3/include/pstl/numeric_impl.h index 75d96411b3d0..0b02bcf07891 100644 --- a/libstdc++-v3/include/pstl/numeric_impl.h +++ b/libstdc++-v3/include/pstl/numeric_impl.h @@ -297,10 +297,10 @@ __brick_adjacent_difference(_ForwardIterator __first, _ForwardIterator __last, _ return std::adjacent_difference(__first, __last, __d_first, __op); } -template +template _ForwardIterator2 __brick_adjacent_difference(_ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first, - BinaryOperation __op, /*is_vector=*/std::true_type) noexcept + _BinaryOperation __op, /*is_vector=*/std::true_type) noexcept { _PSTL_ASSERT(__first != __last); diff --git a/libstdc++-v3/include/pstl/parallel_backend_tbb.h b/libstdc++-v3/include/pstl/parallel_backend_tbb.h index 4476486d5488..3fd1a06ebd89 100644 --- a/libstdc++-v3/include/pstl/parallel_backend_tbb.h +++ b/libstdc++-v3/include/pstl/parallel_backend_tbb.h @@ -803,9 +803,9 @@ class __merge_func struct __cleanup_range { - template + template void - operator()(Iterator __first, Iterator __last) + operator()(_Iterator __first, _Iterator __last) { if (__last - __first < __merge_cut_off) _Cleanup()(__first, __last); diff --git a/libstdc++-v3/include/pstl/unseq_backend_simd.h b/libstdc++-v3/include/pstl/unseq_backend_simd.h index f6265f5c16e5..7cda7ffeddc3 100644 --- a/libstdc++-v3/include/pstl/unseq_backend_simd.h +++ b/libstdc++-v3/include/pstl/unseq_backend_simd.h @@ -532,7 +532,7 @@ struct _Combiner _BinaryOp* __bin_op; // Here is a pointer to function because of default ctor _Combiner() : __value{}, __bin_op(nullptr) {} - _Combiner(const _Tp& value, const _BinaryOp* bin_op) : __value(value), __bin_op(const_cast<_BinaryOp*>(bin_op)) {} + _Combiner(const _Tp& value, const _BinaryOp* __bin_op) : __value(value), __bin_op(const_cast<_BinaryOp*>(__bin_op)) {} _Combiner(const _Combiner& __obj) : __value{}, __bin_op(__obj.__bin_op) {} void @@ -624,8 +624,8 @@ __simd_min_element(_ForwardIterator __first, _Size __n, _Compare __comp) noexcep _Compare* __min_comp; _ComplexType() : __min_val{}, __min_ind{}, __min_comp(nullptr) {} - _ComplexType(const _ValueType& val, const _Compare* comp) - : __min_val(val), __min_ind(0), __min_comp(const_cast<_Compare*>(comp)) + _ComplexType(const _ValueType& __val, const _Compare* comp) + : __min_val(__val), __min_ind(0), __min_comp(const_cast<_Compare*>(comp)) { } _ComplexType(const _ComplexType& __obj) @@ -685,8 +685,8 @@ __simd_minmax_element(_ForwardIterator __first, _Size __n, _Compare __comp) noex _Compare* __minmax_comp; _ComplexType() : __min_val{}, __max_val{}, __min_ind{}, __max_ind{}, __minmax_comp(nullptr) {} - _ComplexType(const _ValueType& min_val, const _ValueType& max_val, const _Compare* comp) - : __min_val(min_val), __max_val(max_val), __min_ind(0), __max_ind(0), + _ComplexType(const _ValueType& __min_val, const _ValueType& __max_val, const _Compare* comp) + : __min_val(__min_val), __max_val(__max_val), __min_ind(0), __max_ind(0), __minmax_comp(const_cast<_Compare*>(comp)) { } diff --git a/libstdc++-v3/testsuite/17_intro/names_pstl.cc b/libstdc++-v3/testsuite/17_intro/names_pstl.cc new file mode 100644 index 000000000000..e5f3ca91aa2e --- /dev/null +++ b/libstdc++-v3/testsuite/17_intro/names_pstl.cc @@ -0,0 +1,16 @@ +// { dg-do compile { target c++17 } } +// { dg-additional-options "-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1" { target tbb_backend} } + +// The TBB headers use non-reserved names (because they're not part of the +// implementation) so we need to include them before the macro definitions +// in names.cc: +#if __has_include() +# include +#endif +// Now we can define the macros to poison uses of non-reserved names: +#include "names.cc" +// And finally, include all the headers that have PSTL content: +#include +#include +#include +#include