From 593cda3e61f6645d4999b7065b6f49ce631567a3 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 17 May 2019 15:13:40 +0100 Subject: [PATCH] Fix uses of non-reserved names for template parameters * include/bits/random.h (seed_seq::param): Fix non-reserved name. * include/experimental/type_traits (is_detected_exact) (is_detected_exact_v): Likewise. * include/pstl/execution_defs.h (is_execution_policy) (is_execution_policy_v, __enable_if_execution_policy): Likewise. * include/pstl/execution_impl.h (__policy_traits): Likewise. * testsuite/17_intro/names.cc: Check for more non-reserved names. * testsuite/experimental/names.cc: New test. From-SVN: r271324 --- libstdc++-v3/ChangeLog | 9 +++ libstdc++-v3/include/bits/random.h | 4 +- libstdc++-v3/include/experimental/type_traits | 8 +- libstdc++-v3/include/pstl/execution_defs.h | 12 +-- libstdc++-v3/include/pstl/execution_impl.h | 2 +- libstdc++-v3/testsuite/17_intro/names.cc | 73 ++++++++++++++++++- libstdc++-v3/testsuite/experimental/names.cc | 64 ++++++++++++++++ 7 files changed, 158 insertions(+), 14 deletions(-) create mode 100644 libstdc++-v3/testsuite/experimental/names.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6e404b228e5..397b8edd327 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 2019-05-17 Jonathan Wakely + * include/bits/random.h (seed_seq::param): Fix non-reserved name. + * include/experimental/type_traits (is_detected_exact) + (is_detected_exact_v): Likewise. + * include/pstl/execution_defs.h (is_execution_policy) + (is_execution_policy_v, __enable_if_execution_policy): Likewise. + * include/pstl/execution_impl.h (__policy_traits): Likewise. + * testsuite/17_intro/names.cc: Check for more non-reserved names. + * testsuite/experimental/names.cc: New test. + PR libstdc++/85965 * include/bits/hashtable.h (_Hashtable::~_Hashtable()): Remove static assertions from the destructor. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 3f5ae53086e..2b1df4cb59e 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -6080,9 +6080,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t size() const noexcept { return _M_v.size(); } - template + template void - param(OutputIterator __dest) const + param(_OutputIterator __dest) const { std::copy(_M_v.begin(), _M_v.end(), __dest); } // no copy functions diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits index c2b2dcc2739..2403bd24223 100644 --- a/libstdc++-v3/include/experimental/type_traits +++ b/libstdc++-v3/include/experimental/type_traits @@ -252,12 +252,12 @@ template class _Op, typename... _Args> template class _Op, typename... _Args> using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; -template class _Op, typename... _Args> - using is_detected_exact = is_same>; +template class _Op, typename... _Args> + using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; -template class _Op, typename... _Args> +template class _Op, typename... _Args> constexpr bool is_detected_exact_v - = is_detected_exact::value; + = is_detected_exact<_Expected, _Op, _Args...>::value; template class _Op, typename... _Args> using is_detected_convertible diff --git a/libstdc++-v3/include/pstl/execution_defs.h b/libstdc++-v3/include/pstl/execution_defs.h index 9a4b49bd46a..1a551c7871c 100644 --- a/libstdc++-v3/include/pstl/execution_defs.h +++ b/libstdc++-v3/include/pstl/execution_defs.h @@ -117,7 +117,7 @@ constexpr parallel_unsequenced_policy par_unseq{}; constexpr unsequenced_policy unseq{}; // 2.3, Execution policy type trait -template +template struct is_execution_policy : std::false_type { }; @@ -142,8 +142,8 @@ struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_ty }; #if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT -template -constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy::value; +template +constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_Tp>::value; #endif } // namespace v1 @@ -151,10 +151,10 @@ constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy namespace __internal { -template +template using __enable_if_execution_policy = - typename std::enable_if<__pstl::execution::is_execution_policy::type>::value, - T>::type; + typename std::enable_if<__pstl::execution::is_execution_policy::type>::value, + _Tp>::type; } // namespace __internal } // namespace __pstl diff --git a/libstdc++-v3/include/pstl/execution_impl.h b/libstdc++-v3/include/pstl/execution_impl.h index 8ee5fa062a8..cbebbbd4239 100644 --- a/libstdc++-v3/include/pstl/execution_impl.h +++ b/libstdc++-v3/include/pstl/execution_impl.h @@ -66,7 +66,7 @@ struct __is_random_access_iterator<_IteratorType> }; /* policy */ -template +template struct __policy_traits { }; diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index c3c753b35e5..20123a41287 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -19,7 +19,6 @@ // Define macros for some common variables names that we must not use for // naming variables, parameters etc. in the library. -#define tmp ( #define A ( #define B ( #define C ( @@ -99,6 +98,78 @@ #define y ( #define z ( +#define tmp ( + +#if __cplusplus < 201703L +// defines to_chars_result::ptr and to_chars_result::ec +#define ec ( +#define ptr ( +#endif + +// Common template parameter names +#define OutputIterator OutputIterator is not a reserved name +#define InputIterator InputIterator is not a reserved name +#define ForwardIterator ForwardIterator is not a reserved name +#define BidirectionalIterator BidirectionalIterator is not a reserved name +#define RandomAccessIterator RandomAccessIterator is not a reserved name +#define RandomAccessOutputIterator RandomAccessOutputIterator is not a reserved name +#define RAIter RAIter is not a reserved name +#define FwdIter FwdIter is not a reserved name +#define OutIter OutIter is not a reserved name +#define InIter InIter is not a reserved name + +#define Alloc Alloc is not a reserved name +#define BinaryFunction1 BinaryFunction1 is not a reserved name +#define BinaryFunction2 BinaryFunction2 is not a reserved name +#define Char Char is not a reserved name +#define CharT CharT is not a reserved name +#define Cmp Cmp is not a reserved name +#define Compare Compare is not a reserved name +#define Const_Iterator Const_Iterator is not a reserved name +#define Const_Key_Reference Const_Key_Reference is not a reserved name +#define Const_Node_Iter Const_Node_Iter is not a reserved name +#define Const_Pointer Const_Pointer is not a reserved name +#define Const_Reference Const_Reference is not a reserved name +#define Data Data is not a reserved name +#define DiffType DiffType is not a reserved name +#define Eq Eq is not a reserved name +#define ExecPolicy ExecPolicy is not a reserved name +#define Expected Expected is not a reserved name +#define External_Load_Access External_Load_Access is not a reserved name +#define External_Size_Access External_Size_Access is not a reserved name +#define Fn Fn is not a reserved name +#define Function Function is not a reserved name +#define Functor Functor is not a reserved name +#define Hash Hash is not a reserved name +#define H1 H1 is not a reserved name +#define H2 H2 is not a reserved name +#define Head Head is not a reserved name +#define It It is not a reserved name +#define Iter Iter is not a reserved name +#define Iterator Iterator is not a reserved name +#define Key Key is not a reserved name +#define Mapped Mapped is not a reserved name +#define Node Node is not a reserved name +#define Node_iter Node_iter is not a reserved name +#define Node_ptr Node_ptr is not a reserved name +#define Overflow Overflow is not a reserved name +#define Pointer Pointer is not a reserved name +#define Policy Policy is not a reserved name +#define Pred Pred is not a reserved name +#define Ptr Ptr is not a reserved name +#define Reference Reference is not a reserved name +#define Seq Seq is not a reserved name +#define Seq_RAIter Seq_RAIter is not a reserved name +#define Series Series is not a reserved name +#define Set Set is not a reserved name +#define String String is not a reserved name +#define Tp Tp is not a reserved name +#define Traits Traits is not a reserved name +#define Type Type is not a reserved name +#define Value Value is not a reserved name +#define ValueT ValueT is not a reserved name +#define ValueType ValueType is not a reserved name + #ifdef _AIX // See https://gcc.gnu.org/ml/libstdc++/2017-03/msg00015.html #undef f diff --git a/libstdc++-v3/testsuite/experimental/names.cc b/libstdc++-v3/testsuite/experimental/names.cc new file mode 100644 index 00000000000..e97baf3d5bd --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/names.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2017-2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } + +// Define macros for some common variables names that we must not use for +// naming variables, parameters etc. in the library. + +#include "../17_intro/names.cc" +// Filesystem +#include +// Library Fundamentals +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Networking +#include +#include +#include +#include +#include +#include +#include +#include -- 2.30.2