Commit d34d36ef by Jonathan Wakely Committed by Jonathan Wakely

PR libstdc++/79789 fix non-reserved names in headers

	PR libstdc++/79789
	* include/bits/hashtable_policy.h (__clp2): Use reserved names for
	parameters and local variables.
	* include/bits/ios_base.h (make_error_code, make_error_condition):
	Likewise.
	* include/bits/list.tcc (list::sort): Likewise.
	* include/bits/mask_array.h (mask_array): Likewise.
	* include/bits/regex.h (regex_token_iterator): Likewise.
	* include/bits/slice_array.h (slice_array): Likewise.
	* include/bits/stl_algo.h (__sample): Likewise.
	* include/std/memory (undeclare_no_pointers): Likewise.
	* include/std/type_traits (is_callable_v, is_nothrow_callable_v):
	Likewise.
	* libsupc++/exception_ptr.h (__dest_thunk): Likewise.
	* testsuite/17_intro/headers/names.cc: New test.

From-SVN: r245828
parent 5782e309
2017-03-02 Jonathan Wakely <jwakely@redhat.com> 2017-03-02 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/79789
* include/bits/hashtable_policy.h (__clp2): Use reserved names for
parameters and local variables.
* include/bits/ios_base.h (make_error_code, make_error_condition):
Likewise.
* include/bits/list.tcc (list::sort): Likewise.
* include/bits/mask_array.h (mask_array): Likewise.
* include/bits/regex.h (regex_token_iterator): Likewise.
* include/bits/slice_array.h (slice_array): Likewise.
* include/bits/stl_algo.h (__sample): Likewise.
* include/std/memory (undeclare_no_pointers): Likewise.
* include/std/type_traits (is_callable_v, is_nothrow_callable_v):
Likewise.
* libsupc++/exception_ptr.h (__dest_thunk): Likewise.
* testsuite/17_intro/headers/names.cc: New test.
PR libstdc++/79798 PR libstdc++/79798
* include/std/functional (bind::_Res_type_impl): Fix incorrect use of * include/std/functional (bind::_Res_type_impl): Fix incorrect use of
result_of that loses top-level cv-qualifiers. result_of that loses top-level cv-qualifiers.
......
...@@ -521,24 +521,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -521,24 +521,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Compute closest power of 2. /// Compute closest power of 2.
_GLIBCXX14_CONSTEXPR _GLIBCXX14_CONSTEXPR
inline std::size_t inline std::size_t
__clp2(std::size_t n) noexcept __clp2(std::size_t __n) noexcept
{ {
#if __SIZEOF_SIZE_T__ >= 8 #if __SIZEOF_SIZE_T__ >= 8
std::uint_fast64_t x = n; std::uint_fast64_t __x = __n;
#else #else
std::uint_fast32_t x = n; std::uint_fast32_t __x = __n;
#endif #endif
// Algorithm from Hacker's Delight, Figure 3-3. // Algorithm from Hacker's Delight, Figure 3-3.
x = x - 1; __x = __x - 1;
x = x | (x >> 1); __x = __x | (__x >> 1);
x = x | (x >> 2); __x = __x | (__x >> 2);
x = x | (x >> 4); __x = __x | (__x >> 4);
x = x | (x >> 8); __x = __x | (__x >> 8);
x = x | (x >>16); __x = __x | (__x >>16);
#if __SIZEOF_SIZE_T__ >= 8 #if __SIZEOF_SIZE_T__ >= 8
x = x | (x >>32); __x = __x | (__x >>32);
#endif #endif
return x + 1; return __x + 1;
} }
/// Rehash policy providing power of 2 bucket numbers. Avoids modulo /// Rehash policy providing power of 2 bucket numbers. Avoids modulo
......
...@@ -207,12 +207,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -207,12 +207,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const error_category& iostream_category() noexcept; const error_category& iostream_category() noexcept;
inline error_code inline error_code
make_error_code(io_errc e) noexcept make_error_code(io_errc __e) noexcept
{ return error_code(static_cast<int>(e), iostream_category()); } { return error_code(static_cast<int>(__e), iostream_category()); }
inline error_condition inline error_condition
make_error_condition(io_errc e) noexcept make_error_condition(io_errc __e) noexcept
{ return error_condition(static_cast<int>(e), iostream_category()); } { return error_condition(static_cast<int>(__e), iostream_category()); }
#endif #endif
// 27.4.2 Class ios_base // 27.4.2 Class ios_base
......
...@@ -500,8 +500,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -500,8 +500,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__catch(...) __catch(...)
{ {
this->splice(this->end(), __carry); this->splice(this->end(), __carry);
for (int i = 0; i < sizeof(__tmp)/sizeof(__tmp[0]); ++i) for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i)
this->splice(this->end(), __tmp[i]); this->splice(this->end(), __tmp[__i]);
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -586,8 +586,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -586,8 +586,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__catch(...) __catch(...)
{ {
this->splice(this->end(), __carry); this->splice(this->end(), __carry);
for (int i = 0; i < sizeof(__tmp)/sizeof(__tmp[0]); ++i) for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i)
this->splice(this->end(), __tmp[i]); this->splice(this->end(), __tmp[__i]);
__throw_exception_again; __throw_exception_again;
} }
} }
......
...@@ -136,8 +136,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -136,8 +136,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}; };
template<typename _Tp> template<typename _Tp>
inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a) inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& __a)
: _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {} : _M_sz(__a._M_sz), _M_mask(__a._M_mask), _M_array(__a._M_array) {}
template<typename _Tp> template<typename _Tp>
inline inline
......
...@@ -2674,9 +2674,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -2674,9 +2674,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
initializer_list<int>, initializer_list<int>,
regex_constants::match_flag_type = regex_constants::match_flag_type =
regex_constants::match_default) = delete; regex_constants::match_default) = delete;
template <std::size_t N> template <std::size_t _Nm>
regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
const int (&)[N], const int (&)[_Nm],
regex_constants::match_flag_type = regex_constants::match_flag_type =
regex_constants::match_default) = delete; regex_constants::match_default) = delete;
......
...@@ -204,8 +204,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -204,8 +204,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp> template<typename _Tp>
inline inline
slice_array<_Tp>::slice_array(const slice_array<_Tp>& a) slice_array<_Tp>::slice_array(const slice_array<_Tp>& __a)
: _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {} : _M_sz(__a._M_sz), _M_stride(__a._M_stride), _M_array(__a._M_array) {}
// template<typename _Tp> // template<typename _Tp>
// inline slice_array<_Tp>::~slice_array () {} // inline slice_array<_Tp>::~slice_array () {}
......
...@@ -5748,11 +5748,11 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -5748,11 +5748,11 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
{ {
while (__n != 0 && __unsampled_sz >= 2) while (__n != 0 && __unsampled_sz >= 2)
{ {
const pair<_Size, _Size> p = const pair<_Size, _Size> __p =
__gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g); __gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g);
--__unsampled_sz; --__unsampled_sz;
if (p.first < __n) if (__p.first < __n)
{ {
*__out++ = *__first; *__out++ = *__first;
--__n; --__n;
...@@ -5763,7 +5763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -5763,7 +5763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
if (__n == 0) break; if (__n == 0) break;
--__unsampled_sz; --__unsampled_sz;
if (p.second < __n) if (__p.second < __n)
{ {
*__out++ = *__first; *__out++ = *__first;
--__n; --__n;
......
...@@ -132,9 +132,9 @@ enum class pointer_safety { relaxed, preferred, strict }; ...@@ -132,9 +132,9 @@ enum class pointer_safety { relaxed, preferred, strict };
inline void inline void
declare_reachable(void*) { } declare_reachable(void*) { }
template <class T> template <typename _Tp>
inline T* inline _Tp*
undeclare_reachable(T* __p) { return __p; } undeclare_reachable(_Tp* __p) { return __p; }
inline void inline void
declare_no_pointers(char*, size_t) { } declare_no_pointers(char*, size_t) { }
......
...@@ -2892,12 +2892,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2892,12 +2892,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }; { };
/// std::is_callable_v /// std::is_callable_v
template<typename T, typename _Ret = void> template<typename _Tp, typename _Ret = void>
constexpr bool is_callable_v = is_callable<T, _Ret>::value; constexpr bool is_callable_v = is_callable<_Tp, _Ret>::value;
/// std::is_nothrow_callable_v /// std::is_nothrow_callable_v
template<typename T, typename _Ret = void> template<typename _Tp, typename _Ret = void>
constexpr bool is_nothrow_callable_v = is_nothrow_callable<T, _Ret>::value; constexpr bool is_nothrow_callable_v
= is_nothrow_callable<_Tp, _Ret>::value;
#endif // C++17 #endif // C++17
......
...@@ -168,8 +168,8 @@ namespace std ...@@ -168,8 +168,8 @@ namespace std
template<typename _Ex> template<typename _Ex>
inline void inline void
__dest_thunk(void* x) __dest_thunk(void* __x)
{ static_cast<_Ex*>(x)->~_Ex(); } { static_cast<_Ex*>(__x)->~_Ex(); }
} // namespace __exception_ptr } // namespace __exception_ptr
......
// Copyright (C) 2017 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
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// 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 (
#define D (
#define E (
#define F (
#define G (
#define H (
#define I (
#define J (
#define K (
#define L (
#define M (
#define N (
#define O (
#define P (
#define Q (
#define R (
#define S (
#define T (
#define U (
#define V (
#define W (
#define X (
#define Y (
#define Z (
#if __cplusplus >= 201103L
// <random> defines member functions called a() and b()
#else
#define a (
#define b (
#endif
// <queue> and <stack> defined data members called c
#define d (
#define e (
#define f (
#define g (
#if __cplusplus >= 201402L
// <chrono> defines operator ""h in C++14
// <complex> defines operator ""i in C++14
#else
#define h (
#define i (
#endif
#define j (
#if __cplusplus >= 201103L
// <random> defines member functions called k()
#else
#define k (
#endif
#define l (
#if __cplusplus >= 201103L
// <random> defines member functions called m() and n()
#else
#define m (
#define n (
#endif
#define o (
#if __cplusplus >= 201103L
// <random> defines member functions called p()
#else
#define p (
#endif
#define q (
#define r (
#if __cplusplus >= 201103L
// <random> defines member functions called s() and t()
// <chrono> and <string> define operator ""s in C++14
#else
#define s (
#define t (
#endif
#define u (
#define v (
#define w (
#define x (
#define y (
#define z (
#include <bits/stdc++.h>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment