public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6078] libstdc++: Fix non-reserved names in PSTL headers
@ 2023-02-16 11:37 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-02-16 11:37 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:cb6beb887e64935c12a3508ead6d1806ef341ba2

commit r13-6078-gcb6beb887e64935c12a3508ead6d1806ef341ba2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat Feb 11 00:24:47 2023 +0000

    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:
---
 libstdc++-v3/include/pstl/algorithm_fwd.h        | 36 ++++++++++++------------
 libstdc++-v3/include/pstl/algorithm_impl.h       | 28 +++++++++---------
 libstdc++-v3/include/pstl/execution_impl.h       |  8 +++---
 libstdc++-v3/include/pstl/glue_algorithm_impl.h  |  2 +-
 libstdc++-v3/include/pstl/glue_numeric_defs.h    |  2 +-
 libstdc++-v3/include/pstl/numeric_impl.h         |  4 +--
 libstdc++-v3/include/pstl/parallel_backend_tbb.h |  4 +--
 libstdc++-v3/include/pstl/unseq_backend_simd.h   | 10 +++----
 libstdc++-v3/testsuite/17_intro/names_pstl.cc    | 16 +++++++++++
 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 814356b38fb..e85125c4dc7 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 8e127b5ba22..32c19990ed0 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 53ff11fca46..e0969a1db9c 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 d2e30529f78..b16306f2e99 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 78df1703079..9029a05f0dd 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 75d96411b3d..0b02bcf0789 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 4476486d548..3fd1a06ebd8 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 f6265f5c16e..7cda7ffeddc 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 00000000000..e5f3ca91aa2
--- /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>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-16 11:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 11:37 [gcc r13-6078] libstdc++: Fix non-reserved names in PSTL headers Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).