From 23f75da95f5e8e09e9fcbd5b0d2885e6c44739aa Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 8 Oct 2020 00:05:53 +0100 Subject: [PATCH] libstdc++: Fix non-reserved names in headers My recent changes to std::exception_ptr moved some members to be inline in the header but didn't replace the variable names with reserved names. The "tmp" variable must be fixed. The "other" parameter is actually a reserved name because of std::allocator::rebind::other but should be fixed anyway. There are also some bad uses of "ForwardIterator" in . There's also a "il" parameter in a std::seed_seq constructor in which is only reserved since C++14. libstdc++-v3/ChangeLog: * include/bits/random.h (seed_seq(initializer_list)): Rename parameter to use reserved name. * include/bits/ranges_algo.h (shift_left, shift_right): Rename template parameters to use reserved name. * libsupc++/exception_ptr.h (exception_ptr): Likewise for parameters and local variables. * testsuite/17_intro/names.cc: Check "il". Do not check "d" and "y" in C++20 mode. --- libstdc++-v3/include/bits/random.h | 2 +- libstdc++-v3/include/bits/ranges_algo.h | 19 ++++++++++--------- libstdc++-v3/libsupc++/exception_ptr.h | 17 +++++++++-------- libstdc++-v3/testsuite/17_intro/names.cc | 13 +++++++++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 19307fbc3ca..4a6558c966a 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -6063,7 +6063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { } template - seed_seq(std::initializer_list<_IntType> il); + seed_seq(std::initializer_list<_IntType> __il); template seed_seq(_InputIterator __begin, _InputIterator __end); diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index 61673e38fa6..f1a4cc24c0d 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -3696,10 +3696,10 @@ namespace ranges } // namespace ranges #define __cpp_lib_shift 201806L - template - constexpr ForwardIterator - shift_left(ForwardIterator __first, ForwardIterator __last, - typename iterator_traits::difference_type __n) + template + constexpr _ForwardIterator + shift_left(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) { __glibcxx_assert(__n >= 0); if (__n == 0) @@ -3711,16 +3711,17 @@ namespace ranges return std::move(std::move(__mid), std::move(__last), std::move(__first)); } - template - constexpr ForwardIterator - shift_right(ForwardIterator __first, ForwardIterator __last, - typename iterator_traits::difference_type __n) + template + constexpr _ForwardIterator + shift_right(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) { __glibcxx_assert(__n >= 0); if (__n == 0) return __first; - using _Cat = typename iterator_traits::iterator_category; + using _Cat + = typename iterator_traits<_ForwardIterator>::iterator_category; if constexpr (derived_from<_Cat, bidirectional_iterator_tag>) { auto __mid = ranges::next(__last, -__n, __first); diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index a053122d48e..4497d0e8581 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -180,8 +180,9 @@ namespace std #ifndef _GLIBCXX_EH_PTR_COMPAT inline #endif - exception_ptr::exception_ptr(const exception_ptr& other) _GLIBCXX_NOEXCEPT - : _M_exception_object(other._M_exception_object) + exception_ptr::exception_ptr(const exception_ptr& __other) + _GLIBCXX_NOEXCEPT + : _M_exception_object(__other._M_exception_object) { if (_M_exception_object) _M_addref(); @@ -200,9 +201,9 @@ namespace std inline #endif exception_ptr& - exception_ptr::operator=(const exception_ptr& other) _GLIBCXX_USE_NOEXCEPT + exception_ptr::operator=(const exception_ptr& __other) _GLIBCXX_USE_NOEXCEPT { - exception_ptr(other).swap(*this); + exception_ptr(__other).swap(*this); return *this; } @@ -210,11 +211,11 @@ namespace std inline #endif void - exception_ptr::swap(exception_ptr &other) _GLIBCXX_USE_NOEXCEPT + exception_ptr::swap(exception_ptr &__other) _GLIBCXX_USE_NOEXCEPT { - void *tmp = _M_exception_object; - _M_exception_object = other._M_exception_object; - other._M_exception_object = tmp; + void *__tmp = _M_exception_object; + _M_exception_object = __other._M_exception_object; + __other._M_exception_object = __tmp; } #ifdef _GLIBCXX_EH_PTR_COMPAT diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 2b6c3eb017d..5a61c97e989 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -52,9 +52,10 @@ #define b ( #endif // and defined data members called c -#define d ( #if __cplusplus <= 201703L -// defines std::numbers::e +// defines operator""d in C++20 +#define d ( +// defines std::numbers::e in C++20 #define e ( #endif #define f ( @@ -98,7 +99,10 @@ #define v ( #define w ( #define x ( +#if __cplusplus <= 201703L +// defines operator""y in C++20 #define y ( +#endif #define z ( #define tmp ( @@ -107,6 +111,11 @@ #define uses_allocator ( #endif +#if __cplusplus < 201402L +// defines operator""il +#define il ( +#endif + #if __cplusplus < 201703L // defines to_chars_result::ptr and to_chars_result::ec #define ec ( -- 2.30.2