From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6DCA13858D33 for ; Thu, 16 Feb 2023 11:40:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DCA13858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676547619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G8RsgIVPdNSJ8wpYq0LXB1zoFPhBZhnNMa6FTAn6RJQ=; b=ed1lV0O+3ok63fK2Yd2hE+7I3dednUiPBeGWZYzqFImLqcB3F5cjQqHD8altXHmPZpWWiN M3KV9osF/kiv34q6/3xsrP3TZ7sOg9iBSW4WsvtsFeVgKBzId2M4ZMW0tWOx2O4M5EnEiL kwMGAugReRpCfXfY3ynFXWtXJQD/DoM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-rtAlPrXQN5ysQ_ywCOvO4w-1; Thu, 16 Feb 2023 06:40:17 -0500 X-MC-Unique: rtAlPrXQN5ysQ_ywCOvO4w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D2A1183B3C3; Thu, 16 Feb 2023 11:40:17 +0000 (UTC) Received: from localhost (unknown [10.33.37.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 467C52166B31; Thu, 16 Feb 2023 11:40:17 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Thomas Rodgers Subject: [committed] libstdc++: Fix non-reserved names in PSTL headers Date: Thu, 16 Feb 2023 11:40:16 +0000 Message-Id: <20230216114016.105674-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- 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 | 36 +++++++++---------- libstdc++-v3/include/pstl/algorithm_impl.h | 28 +++++++-------- libstdc++-v3/include/pstl/execution_impl.h | 8 ++--- .../include/pstl/glue_algorithm_impl.h | 2 +- libstdc++-v3/include/pstl/glue_numeric_defs.h | 2 +- libstdc++-v3/include/pstl/numeric_impl.h | 4 +-- .../include/pstl/parallel_backend_tbb.h | 4 +-- .../include/pstl/unseq_backend_simd.h | 10 +++--- libstdc++-v3/testsuite/17_intro/names_pstl.cc | 16 +++++++++ 9 files changed, 63 insertions(+), 47 deletions(-) create mode 100644 libstdc++-v3/testsuite/17_intro/names_pstl.cc 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 _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 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 -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 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 +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 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 __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 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 +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 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 + 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 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() +# 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 -- 2.39.1