]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix non-reserved names in PSTL headers
authorJonathan Wakely <jwakely@redhat.com>
Sat, 11 Feb 2023 00:24:47 +0000 (00:24 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 16 Feb 2023 11:34:20 +0000 (11:34 +0000)
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.

libstdc++-v3/include/pstl/algorithm_fwd.h
libstdc++-v3/include/pstl/algorithm_impl.h
libstdc++-v3/include/pstl/execution_impl.h
libstdc++-v3/include/pstl/glue_algorithm_impl.h
libstdc++-v3/include/pstl/glue_numeric_defs.h
libstdc++-v3/include/pstl/numeric_impl.h
libstdc++-v3/include/pstl/parallel_backend_tbb.h
libstdc++-v3/include/pstl/unseq_backend_simd.h
libstdc++-v3/testsuite/17_intro/names_pstl.cc [new file with mode: 0644]

index 814356b38fb74560d2d176a6718ae4b2c8c50c89..e85125c4dc70a09f84835b222877ed627aab78fa 100644 (file)
@@ -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);
 
 //------------------------------------------------------------------------
index 8e127b5ba22453b4ad930651c8f07b137f1f30d2..32c19990ed0fb4c1993ff9702cffcc3fc34b0176 100644 (file)
@@ -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);
 }
index 53ff11fca46ed2433d8098fe97d854ce04b8ad5c..e0969a1db9c1128953b73aa3852295fc814a5af4 100644 (file)
@@ -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;
 };
index d2e30529f785d5bb2b1e6f161b1d2fcfc9d91b1a..b16306f2e99036f97ce562eb8b0f5805a3bffff5 100644 (file)
@@ -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,
index 78df17030793e74d5797734c09881103229373e1..9029a05f0ddd4633218f068d206f8a46bae257f5 100644 (file)
@@ -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>
index 75d96411b3d0f92da2cf27dddfa8ec03012ec583..0b02bcf0789178a879b6517f54dd1206d737828c 100644 (file)
@@ -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);
 
index 4476486d5488a288261d6ebcac7c746336057c51..3fd1a06ebd89fc749f3bacaa2b7d5d3d26fc8e58 100644 (file)
@@ -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);
index f6265f5c16e5addd9f1e90133d5bf9d28c52f38e..7cda7ffeddc3085b90008361ef49ae2d695c2733 100644 (file)
@@ -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 (file)
index 0000000..e5f3ca9
--- /dev/null
@@ -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>