libstdc++: Make debug containers prefer copy ctor to base ctor (PR 90102)
When given a type which can convert to any container-like type, the C(const C&) copy constructor and C(const C::_Base&) converting constructor are ambiguous. This change replaces the converting constructor's parameter with a reference_wrapper-like type so that calling that constructor requires an additional user-defined conversion. This gives it a lower rank than the copy constructor, avoiding the ambiguity. While testing this change I discovered that __gnu_debug::forward_list doesn't have a convering constructor from the std::forward_list base, so this adds it. We should probably consider whether the converting constructors should be 'explicit' but I'm not changing that now. libstdc++-v3/ChangeLog: PR libstdc++/90102 * include/debug/deque (deque(const _Base&)): Replace parameter with a struct that wraps a const _Base&. * include/debug/forward_list (forward_list(_Base_ref)): New constructor. * include/debug/list (list(const _Base&)): Replace parameter with a struct that wraps a const _Base&. * include/debug/map.h (map(const _Base&)): Likewise. * include/debug/multimap.h (multimap(const _Base&)): Likewise. * include/debug/multiset.h (multiset(const _Base&)): Likewise. * include/debug/set.h (set(const _Base&)): Likewise. * include/debug/unordered_map (unordered_map(const _Base&)) (unordered_multimap(const _Base&)): Likewise. * include/debug/unordered_set (unordered_set(const _Base&)) (unordered_multiset(const _Base&)): Likewise. * testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adjust dg-error line number. * include/debug/vector (vector(const _Base&)): Likewise. * testsuite/23_containers/deque/debug/90102.cc: New test. * testsuite/23_containers/forward_list/debug/90102.cc: New test. * testsuite/23_containers/list/debug/90102.cc: New test. * testsuite/23_containers/map/debug/90102.cc: New test. * testsuite/23_containers/multimap/debug/90102.cc: New test. * testsuite/23_containers/multiset/debug/90102.cc: New test. * testsuite/23_containers/set/debug/90102.cc: New test. * testsuite/23_containers/unordered_map/debug/90102.cc: New test. * testsuite/23_containers/unordered_multimap/debug/90102.cc: New test. * testsuite/23_containers/unordered_multiset/debug/90102.cc: New test. * testsuite/23_containers/unordered_set/debug/90102.cc: New test. * testsuite/23_containers/vector/debug/90102.cc: New test.
This commit is contained in:
parent
95827968e5
commit
eca833b812
@ -64,6 +64,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates deque(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::reference reference;
|
||||
typedef typename _Base::const_reference const_reference;
|
||||
@ -143,8 +153,8 @@ namespace __debug
|
||||
__gnu_debug::__base(__last), __a)
|
||||
{ }
|
||||
|
||||
deque(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
deque(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
deque&
|
||||
|
@ -201,6 +201,14 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::reference reference;
|
||||
typedef typename _Base::const_reference const_reference;
|
||||
@ -265,6 +273,8 @@ namespace __debug
|
||||
|
||||
~forward_list() = default;
|
||||
|
||||
forward_list(_Base_ref __x) : _Base(__x._M_ref) { }
|
||||
|
||||
forward_list&
|
||||
operator=(const forward_list&) = default;
|
||||
|
||||
|
@ -65,6 +65,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates list(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::reference reference;
|
||||
typedef typename _Base::const_reference const_reference;
|
||||
@ -144,8 +154,8 @@ namespace __debug
|
||||
__gnu_debug::__base(__last), __a)
|
||||
{ }
|
||||
|
||||
list(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
list(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
list&
|
||||
|
@ -59,6 +59,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates map(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
// types:
|
||||
typedef _Key key_type;
|
||||
@ -126,8 +136,8 @@ namespace __debug
|
||||
~map() = default;
|
||||
#endif
|
||||
|
||||
map(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
map(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
explicit map(const _Compare& __comp,
|
||||
const _Allocator& __a = _Allocator())
|
||||
|
@ -59,6 +59,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates multimap(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
// types:
|
||||
typedef _Key key_type;
|
||||
@ -138,8 +148,8 @@ namespace __debug
|
||||
__gnu_debug::__base(__last),
|
||||
__comp, __a) { }
|
||||
|
||||
multimap(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
multimap(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
multimap&
|
||||
|
@ -58,6 +58,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates multiset(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
// types:
|
||||
typedef _Key key_type;
|
||||
@ -138,8 +148,8 @@ namespace __debug
|
||||
__gnu_debug::__base(__last),
|
||||
__comp, __a) { }
|
||||
|
||||
multiset(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
multiset(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
multiset&
|
||||
|
@ -58,6 +58,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates set(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
// types:
|
||||
typedef _Key key_type;
|
||||
@ -137,8 +147,8 @@ namespace __debug
|
||||
__gnu_debug::__base(__last),
|
||||
__comp, __a) { }
|
||||
|
||||
set(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
set(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
set&
|
||||
|
@ -81,6 +81,14 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT>
|
||||
friend class ::__gnu_debug::_Safe_local_iterator;
|
||||
|
||||
// Reference wrapper for base class. See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef typename _Base::hasher hasher;
|
||||
@ -121,8 +129,8 @@ namespace __debug
|
||||
|
||||
unordered_map(const unordered_map&) = default;
|
||||
|
||||
unordered_map(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
unordered_map(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
unordered_map(unordered_map&&) = default;
|
||||
|
||||
@ -776,6 +784,14 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT>
|
||||
friend class ::__gnu_debug::_Safe_local_iterator;
|
||||
|
||||
// Reference wrapper for base class. See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef typename _Base::hasher hasher;
|
||||
@ -816,8 +832,8 @@ namespace __debug
|
||||
|
||||
unordered_multimap(const unordered_multimap&) = default;
|
||||
|
||||
unordered_multimap(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
unordered_multimap(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
unordered_multimap(unordered_multimap&&) = default;
|
||||
|
||||
|
@ -78,6 +78,14 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT>
|
||||
friend class ::__gnu_debug::_Safe_local_iterator;
|
||||
|
||||
// Reference wrapper for base class. See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef typename _Base::hasher hasher;
|
||||
@ -118,8 +126,8 @@ namespace __debug
|
||||
|
||||
unordered_set(const unordered_set&) = default;
|
||||
|
||||
unordered_set(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
unordered_set(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
unordered_set(unordered_set&&) = default;
|
||||
|
||||
@ -646,6 +654,14 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT>
|
||||
friend class ::__gnu_debug::_Safe_local_iterator;
|
||||
|
||||
// Reference wrapper for base class. See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef typename _Base::hasher hasher;
|
||||
@ -686,8 +702,8 @@ namespace __debug
|
||||
|
||||
unordered_multiset(const unordered_multiset&) = default;
|
||||
|
||||
unordered_multiset(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
unordered_multiset(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
unordered_multiset(unordered_multiset&&) = default;
|
||||
|
||||
|
@ -135,6 +135,16 @@ namespace __debug
|
||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||
friend class ::__gnu_debug::_Safe_iterator;
|
||||
|
||||
// Reference wrapper for base class. Disambiguates vector(const _Base&)
|
||||
// from copy constructor by requiring a user-defined conversion.
|
||||
// See PR libstdc++/90102.
|
||||
struct _Base_ref
|
||||
{
|
||||
_Base_ref(const _Base& __r) : _M_ref(__r) { }
|
||||
|
||||
const _Base& _M_ref;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename _Base::reference reference;
|
||||
typedef typename _Base::const_reference const_reference;
|
||||
@ -207,8 +217,8 @@ namespace __debug
|
||||
: _Base(__x, __a) { }
|
||||
|
||||
vector(vector&& __x, const allocator_type& __a)
|
||||
noexcept( noexcept(
|
||||
_Base(std::declval<_Base&&>()), std::declval<const allocator_type&>()) )
|
||||
noexcept(noexcept(
|
||||
_Base(std::declval<_Base&&>()), std::declval<const allocator_type&>()))
|
||||
: _Safe(std::move(__x._M_safe()), __a),
|
||||
_Base(std::move(__x._M_base()), __a),
|
||||
_Safe_vector(std::move(__x)) { }
|
||||
@ -221,8 +231,8 @@ namespace __debug
|
||||
#endif
|
||||
|
||||
/// Construction from a normal-mode vector
|
||||
vector(const _Base& __x)
|
||||
: _Base(__x) { }
|
||||
vector(_Base_ref __x)
|
||||
: _Base(__x._M_ref) { }
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
vector&
|
||||
|
34
libstdc++-v3/testsuite/23_containers/deque/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/deque/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/deque>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::deque<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::deque<int> d(static_cast<std::deque<int>>(a));
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/forward_list>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::forward_list<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::forward_list<int> d(static_cast<std::forward_list<int>>(a));
|
34
libstdc++-v3/testsuite/23_containers/list/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/list/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/list>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::list<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::list<int> d(static_cast<std::list<int>>(a));
|
34
libstdc++-v3/testsuite/23_containers/map/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/map/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/map>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::map<int, int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::map<int, int> d(static_cast<std::map<int, int>>(a));
|
34
libstdc++-v3/testsuite/23_containers/multimap/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/multimap/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/map>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::multimap<int, int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::multimap<int, int> d(static_cast<std::multimap<int, int>>(a));
|
34
libstdc++-v3/testsuite/23_containers/multiset/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/multiset/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/set>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::multiset<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::multiset<int> d(static_cast<std::multiset<int>>(a));
|
34
libstdc++-v3/testsuite/23_containers/set/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/set/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/set>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::set<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::set<int> d(static_cast<std::set<int>>(a));
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/unordered_map>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::unordered_map<int, int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::unordered_map<int, int> d(static_cast<std::unordered_map<int, int>>(a));
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/unordered_map>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::unordered_multimap<int, int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::unordered_multimap<int, int> d(static_cast<std::unordered_multimap<int, int>>(a));
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/unordered_set>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::unordered_multiset<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::unordered_multiset<int> d(static_cast<std::unordered_multiset<int>>(a));
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/unordered_set>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::unordered_set<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::unordered_set<int> d(static_cast<std::unordered_set<int>>(a));
|
@ -46,7 +46,7 @@ test02()
|
||||
// { dg-error "value type is destructible" "" { target *-*-* } 0 }
|
||||
|
||||
// In Debug Mode the "required from here" errors come from <debug/vector>
|
||||
// { dg-error "required from here" "" { target *-*-* } 163 }
|
||||
// { dg-error "required from here" "" { target *-*-* } 173 }
|
||||
|
||||
// Needed because of PR c++/92193
|
||||
// { dg-prune-output "deleted function" }
|
||||
|
34
libstdc++-v3/testsuite/23_containers/vector/debug/90102.cc
Normal file
34
libstdc++-v3/testsuite/23_containers/vector/debug/90102.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 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 { target c++11 } }
|
||||
|
||||
#include <debug/vector>
|
||||
|
||||
// PR libstdc++/90102
|
||||
|
||||
struct AnyCont
|
||||
{
|
||||
template<class Cont, class Check = decltype(std::declval<Cont>().clear())>
|
||||
operator Cont () const;
|
||||
} a;
|
||||
|
||||
// This should use copy constructor, not be ambiguous
|
||||
__gnu_debug::vector<int> c(a);
|
||||
|
||||
// Ensure construction from base container still works
|
||||
__gnu_debug::vector<int> d(static_cast<std::vector<int>>(a));
|
Loading…
Reference in New Issue
Block a user