aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-02-11 00:24:47 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-02-16 11:34:20 +0000
commitcb6beb887e64935c12a3508ead6d1806ef341ba2 (patch)
treede06cac451cc60edba9e1cb781ac9601a7e7fb25
parent0b9bd33d69d0c30330a465e6bad262d90c94d4ea (diff)
downloadgcc-cb6beb887e64935c12a3508ead6d1806ef341ba2.zip
gcc-cb6beb887e64935c12a3508ead6d1806ef341ba2.tar.gz
gcc-cb6beb887e64935c12a3508ead6d1806ef341ba2.tar.bz2
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.
-rw-r--r--libstdc++-v3/include/pstl/algorithm_fwd.h36
-rw-r--r--libstdc++-v3/include/pstl/algorithm_impl.h28
-rw-r--r--libstdc++-v3/include/pstl/execution_impl.h8
-rw-r--r--libstdc++-v3/include/pstl/glue_algorithm_impl.h2
-rw-r--r--libstdc++-v3/include/pstl/glue_numeric_defs.h2
-rw-r--r--libstdc++-v3/include/pstl/numeric_impl.h4
-rw-r--r--libstdc++-v3/include/pstl/parallel_backend_tbb.h4
-rw-r--r--libstdc++-v3/include/pstl/unseq_backend_simd.h10
-rw-r--r--libstdc++-v3/testsuite/17_intro/names_pstl.cc16
9 files changed, 63 insertions, 47 deletions
diff --git a/libstdc++-v3/include/pstl/algorithm_fwd.h b/libstdc++-v3/include/pstl/algorithm_fwd.h
index 814356b..e85125c 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 _ExecutionPolicy, class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate,
- class IsVector>
+ class _IsVector>
_ForwardIterator
__pattern_search_n(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Size, const _Tp&, _BinaryPredicate,
- IsVector,
+ _IsVector,
/*is_parallel=*/std::false_type) noexcept;
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Tp, class _BinaryPredicate,
- class IsVector>
+ 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 <class _ForwardIterator, class OutputIterator, class _BinaryPredicate>
-OutputIterator __brick_unique_copy(_ForwardIterator, _ForwardIterator, OutputIterator, _BinaryPredicate,
+template <class _ForwardIterator, class _OutputIterator, class _BinaryPredicate>
+ _OutputIterator __brick_unique_copy(_ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryPredicate,
/*vector=*/std::false_type) noexcept;
template <class _RandomAccessIterator, class _OutputIterator, class _BinaryPredicate>
@@ -823,12 +823,12 @@ __pattern_partial_sort_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterat
template <class _ForwardIterator, class _BinaryPredicate>
_ForwardIterator
__brick_adjacent_find(_ForwardIterator, _ForwardIterator, _BinaryPredicate,
- /* IsVector = */ std::true_type, bool) noexcept;
+ /* _IsVector = */ std::true_type, bool) noexcept;
template <class _ForwardIterator, class _BinaryPredicate>
_ForwardIterator
__brick_adjacent_find(_ForwardIterator, _ForwardIterator, _BinaryPredicate,
- /* IsVector = */ std::false_type, bool) noexcept;
+ /* _IsVector = */ std::false_type, bool) noexcept;
template <class _ExecutionPolicy, class _ForwardIterator, class _BinaryPredicate, class _IsVector>
_ForwardIterator
@@ -920,22 +920,22 @@ _ForwardIterator
__pattern_generate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Generator,
/*is_parallel=*/std::true_type, _IsVector);
-template <class OutputIterator, class Size, class _Generator>
-OutputIterator __brick_generate_n(OutputIterator, Size, _Generator,
+template <class _OutputIterator, class _Size, class _Generator>
+ _OutputIterator __brick_generate_n(_OutputIterator, _Size, _Generator,
/* is_vector = */ std::true_type) noexcept;
-template <class OutputIterator, class Size, class _Generator>
-OutputIterator __brick_generate_n(OutputIterator, Size, _Generator,
+template <class _OutputIterator, class _Size, class _Generator>
+ _OutputIterator __brick_generate_n(_OutputIterator, _Size, _Generator,
/* is_vector = */ std::false_type) noexcept;
-template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
-OutputIterator
-__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator,
+template <class _ExecutionPolicy, class _OutputIterator, class _Size, class _Generator, class _IsVector>
+ _OutputIterator
+__pattern_generate_n(_ExecutionPolicy&&, _OutputIterator, _Size, _Generator,
/*is_parallel=*/std::false_type, _IsVector) noexcept;
-template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
-OutputIterator
-__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator,
+template <class _ExecutionPolicy, class _OutputIterator, class _Size, class _Generator, class _IsVector>
+ _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 8e127b5..32c1999 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 <class _ForwardIterator, class OutputIterator, class _BinaryPredicate>
-OutputIterator
-__brick_unique_copy(_ForwardIterator __first, _ForwardIterator __last, OutputIterator __result, _BinaryPredicate __pred,
+template <class _ForwardIterator, class _OutputIterator, class _BinaryPredicate>
+ _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 <class _RandomAccessIterator, class OutputIterator, class _BinaryPredicate>
-OutputIterator
-__brick_unique_copy(_RandomAccessIterator __first, _RandomAccessIterator __last, OutputIterator __result,
+template <class _RandomAccessIterator, class _OutputIterator, class _BinaryPredicate>
+ _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 <class _ExecutionPolicy, class _BidirectionalIterator, class _IsVector>
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 <class _ExecutionPolicy, class _BidirectionalIterator, class _IsVector>
@@ -2514,16 +2514,16 @@ __pattern_generate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forward
});
}
-template <class OutputIterator, class Size, class _Generator>
-OutputIterator
-__brick_generate_n(OutputIterator __first, Size __count, _Generator __g, /* is_vector = */ std::true_type) noexcept
+template <class _OutputIterator, class _Size, class _Generator>
+ _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 <class OutputIterator, class Size, class _Generator>
-OutputIterator
-__brick_generate_n(OutputIterator __first, Size __count, _Generator __g, /* is_vector = */ std::false_type) noexcept
+template <class _OutputIterator, class _Size, class _Generator>
+ _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 53ff11f..e0969a1 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 <typename policy, typename... _IteratorTypes>
+template <typename __policy, typename... _IteratorTypes>
struct __prefer_unsequenced_tag
{
- static constexpr bool value = __internal::__allow_unsequenced<policy>::value &&
+ static constexpr bool value = __internal::__allow_unsequenced<__policy>::value &&
__internal::__is_random_access_iterator<_IteratorTypes...>::value;
typedef std::integral_constant<bool, value> type;
};
-template <typename policy, typename... _IteratorTypes>
+template <typename __policy, typename... _IteratorTypes>
struct __prefer_parallel_tag
{
- static constexpr bool value = __internal::__allow_parallel<policy>::value &&
+ static constexpr bool value = __internal::__allow_parallel<__policy>::value &&
__internal::__is_random_access_iterator<_IteratorTypes...>::value;
typedef std::integral_constant<bool, value> type;
};
diff --git a/libstdc++-v3/include/pstl/glue_algorithm_impl.h b/libstdc++-v3/include/pstl/glue_algorithm_impl.h
index d2e3052..b16306f 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 78df170..9029a05 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 <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation>
__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 <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2>
__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 75d9641..0b02bcf 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 <class _ForwardIterator1, class _ForwardIterator2, class BinaryOperation>
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation>
_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 4476486..3fd1a06 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 <typename Iterator>
+ template <typename _Iterator>
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 f6265f5..7cda7ff 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 0000000..e5f3ca9
--- /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(<tbb/tbb.h>)
+# include <tbb/tbb.h>
+#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 <execution>
+#include <algorithm>
+#include <memory>
+#include <numeric>