diff options
author | yroux <yroux@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-13 13:08:40 +0000 |
---|---|---|
committer | yroux <yroux@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-13 13:08:40 +0000 |
commit | 046f847b355ce3abb3f630e4c619f362762c6f6d (patch) | |
tree | eaef0b753f90eaa91b50073b17ba5e5b87c90600 /libstdc++-v3 | |
parent | edc61985c4d36d8778457ad0cc7b1559593e0024 (diff) | |
download | linaro-gcc-046f847b355ce3abb3f630e4c619f362762c6f6d.tar.gz linaro-gcc-046f847b355ce3abb3f630e4c619f362762c6f6d.tar.bz2 linaro-gcc-046f847b355ce3abb3f630e4c619f362762c6f6d.zip |
Merge branches/gcc-4_9-branch rev 210052
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_9-branch@210370 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
17 files changed, 269 insertions, 37 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a88c29a980c..12e6b5c56ff 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,41 @@ +2014-05-02 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/59476 + * python/libstdcxx/v6/printers.py (get_value_from_Rb_tree_node): New + function to handle both C++03 and C++11 _Rb_tree_node implementations. + (StdRbtreeIteratorPrinter, StdMapPrinter, StdSetPrinter): Use it. + * testsuite/libstdc++-prettyprinters/simple.cc: Update comment to + refer to... + * testsuite/libstdc++-prettyprinters/simple11.cc: New. + + PR libstdc++/61036 + * include/bits/shared_ptr_base.h (__shared_ptr::__shared_ptr(_Tp1*)): + Check the correct type in the static assertion. + * testsuite/20_util/shared_ptr/cons/61036.cc: New. + +2014-04-27 Lars Gullik Bjønnes <larsbj@gullik.org> + + PR libstdc++/60710 + * include/experimental/optional (operator!=): Implement in terms of + operator==. + * testsuite/experimental/optional/relops/1.cc: Remove operator!=. + * testsuite/experimental/optional/relops/2.cc: Likewise. + * testsuite/experimental/optional/relops/3.cc: Likewise. + * testsuite/experimental/optional/relops/4.cc: Likewise. + * testsuite/experimental/optional/relops/5.cc: Likewise. + * testsuite/experimental/optional/relops/6.cc: Likewise. + +2014-04-27 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/60497 + * include/std/tuple (get): Qualify calls to prevent ADL. + * testsuite/20_util/tuple/60497.cc: New. + + * include/std/tuple (tuple_element_t): Define. + * testsuite/20_util/tuple/tuple_element.cc: Change to compile-only + test. + * testsuite/20_util/tuple/tuple_element_t.cc: New. + 2014-04-22 Release Manager * GCC 4.9.0 released. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 536df017d11..026c5979fae 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -871,7 +871,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_ptr(__p), _M_refcount(__p) { __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) - static_assert( !is_void<_Tp>::value, "incomplete type" ); + static_assert( !is_void<_Tp1>::value, "incomplete type" ); static_assert( sizeof(_Tp1) > 0, "incomplete type" ); __enable_shared_from_this_helper(_M_refcount, __p, __p); } diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index 5f2d93fb7f6..2a3f29dcd70 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -736,12 +736,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> constexpr bool operator!=(const optional<_Tp>& __lhs, _Tp const& __rhs) - { return !__lhs || *__lhs != __rhs; } + { return !__lhs || !(*__lhs == __rhs); } template<typename _Tp> constexpr bool operator!=(const _Tp& __lhs, const optional<_Tp>& __rhs) - { return !__rhs || __lhs != *__rhs; } + { return !__rhs || !(__lhs == *__rhs); } template<typename _Tp> constexpr bool diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 92ecdb9bc5b..03d87d77aa0 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -710,6 +710,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION add_cv<typename tuple_element<__i, _Tp>::type>::type type; }; +#if __cplusplus > 201103L + template<std::size_t __i, typename _Tp> + using tuple_element_t = typename tuple_element<__i, _Tp>::type; +#endif + /// Finds the size of a given tuple type. template<typename _Tp> struct tuple_size; @@ -755,14 +760,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename tuple_element<__i, tuple<_Elements...>>::type >::type get(tuple<_Elements...>& __t) noexcept - { return __get_helper<__i>(__t); } + { return std::__get_helper<__i>(__t); } template<std::size_t __i, typename... _Elements> constexpr typename __add_c_ref< typename tuple_element<__i, tuple<_Elements...>>::type >::type get(const tuple<_Elements...>& __t) noexcept - { return __get_helper<__i>(__t); } + { return std::__get_helper<__i>(__t); } template<std::size_t __i, typename... _Elements> constexpr typename __add_r_ref< @@ -786,17 +791,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template <typename _Tp, typename... _Types> constexpr _Tp& get(tuple<_Types...>& __t) noexcept - { return __get_helper2<_Tp>(__t); } + { return std::__get_helper2<_Tp>(__t); } template <typename _Tp, typename... _Types> constexpr _Tp&& get(tuple<_Types...>&& __t) noexcept - { return std::move(__get_helper2<_Tp>(__t)); } + { return std::move(std::__get_helper2<_Tp>(__t)); } template <typename _Tp, typename... _Types> constexpr const _Tp& get(const tuple<_Types...>& __t) noexcept - { return __get_helper2<_Tp>(__t); } + { return std::__get_helper2<_Tp>(__t); } #endif // This class helps construct the various comparison operations on tuples diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 05da17b61ea..1f1f860a5b0 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -375,6 +375,22 @@ class RbtreeIterator: self.node = node return result +def get_value_from_Rb_tree_node(node): + """Returns the value held in an _Rb_tree_node<_Val>""" + try: + member = node.type.fields()[1].name + if member == '_M_value_field': + # C++03 implementation, node contains the value as a member + return node['_M_value_field'] + elif member == '_M_storage': + # C++11 implementation, node stores value in __aligned_buffer + p = node['_M_storage']['_M_storage'].address + p = p.cast(node.type.template_argument(0).pointer()) + return p.dereference() + except: + pass + raise ValueError, "Unsupported implementation for %s" % str(node.type) + # This is a pretty printer for std::_Rb_tree_iterator (which is # std::map::iterator), and has nothing to do with the RbtreeIterator # class above. @@ -387,7 +403,8 @@ class StdRbtreeIteratorPrinter: def to_string (self): typename = str(self.val.type.strip_typedefs()) + '::_Link_type' nodetype = gdb.lookup_type(typename).strip_typedefs() - return self.val.cast(nodetype).dereference()['_M_value_field'] + node = self.val.cast(nodetype).dereference() + return get_value_from_Rb_tree_node(node) class StdDebugIteratorPrinter: "Print a debug enabled version of an iterator" @@ -417,7 +434,8 @@ class StdMapPrinter: def next(self): if self.count % 2 == 0: n = self.rbiter.next() - n = n.cast(self.type).dereference()['_M_value_field'] + n = n.cast(self.type).dereference() + n = get_value_from_Rb_tree_node(n) self.pair = n item = n['first'] else: @@ -458,7 +476,8 @@ class StdSetPrinter: def next(self): item = self.rbiter.next() - item = item.cast(self.type).dereference()['_M_value_field'] + item = item.cast(self.type).dereference() + item = get_value_from_Rb_tree_node(item) # FIXME: this is weird ... what to do? # Maybe a 'set' display hint? result = ('[%d]' % self.count, item) diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/61036.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/61036.cc new file mode 100644 index 00000000000..9cade66487e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/61036.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2014 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/>. + +// 20.8.2.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +void test01() +{ + std::shared_ptr<void> p(new int); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/60497.cc b/libstdc++-v3/testsuite/20_util/tuple/60497.cc new file mode 100644 index 00000000000..76d4223165f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/60497.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// Copyright (C) 2014 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/>. + +// libstdc++/60497 + +#include <tuple> + +struct A; +template<typename T> struct B { T t; }; + +using element_type = B<A>*; +using tuple_type = std::tuple<element_type>; + +tuple_type t; +const tuple_type ct; + +auto a = std::get<0>(t); +auto b = std::get<0>(ct); +auto c = std::get<element_type>(t); +auto d = std::get<element_type>(ct); diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc index 0dbdf10fc99..3ff8e824f60 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc @@ -1,4 +1,5 @@ -// { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } // Copyright (C) 2007-2014 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_element_t.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_element_t.cc new file mode 100644 index 00000000000..e46af5c305d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_element_t.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// Copyright (C) 2014 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/>. + +#include <tuple> + +using namespace std; + +struct foo +{ }; + +int +main() +{ + // As foo isn't constructible from anything else, this + // lets us check if the alias is returning foo when it should + foo q1; + tuple_element_t<0,tuple<foo,void,int> > q2(q1); + tuple_element_t<2,tuple<void,int,foo> > q3(q1); +} diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/1.cc b/libstdc++-v3/testsuite/experimental/optional/relops/1.cc index f1408805ac2..3f1ee9c4900 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/1.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/1.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/2.cc b/libstdc++-v3/testsuite/experimental/optional/relops/2.cc index c7fc848deb0..6ee9cba768a 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/2.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/2.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/3.cc b/libstdc++-v3/testsuite/experimental/optional/relops/3.cc index 9729000d5ca..581d0168fbc 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/3.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/3.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/4.cc b/libstdc++-v3/testsuite/experimental/optional/relops/4.cc index 45378f688e4..ce16fcb92f5 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/4.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/4.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/5.cc b/libstdc++-v3/testsuite/experimental/optional/relops/5.cc index 008409ef402..c01bba57a5e 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/5.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/5.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/6.cc b/libstdc++-v3/testsuite/experimental/optional/relops/6.cc index b17914062ee..a24622b5f40 100644 --- a/libstdc++-v3/testsuite/experimental/optional/relops/6.cc +++ b/libstdc++-v3/testsuite/experimental/optional/relops/6.cc @@ -37,10 +37,6 @@ namespace ns { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); } bool - operator!=(value_type const& lhs, value_type const& rhs) - { return !(lhs == rhs); } - - bool operator<(value_type const& lhs, value_type const& rhs) { return std::tie(lhs.i, lhs.s) < std::tie(rhs.i, rhs.s); } diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index 66ae8f70e56..030207aa67c 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -1,4 +1,4 @@ -// If you modify this, please update debug.cc as well. +// If you modify this, please update simple11.cc and debug.cc as well. // { dg-do run } // { dg-options "-g -O0" } diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc new file mode 100644 index 00000000000..e94bea6ec84 --- /dev/null +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc @@ -0,0 +1,92 @@ +// If you modify this, please update simple.cc and debug.cc as well. + +// { dg-do run } +// { dg-options "-g -O0 -std=gnu++11" } + +// Copyright (C) 2011-2014 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/>. + +#include <string> +#include <deque> +#include <bitset> +#include <iostream> +#include <list> +#include <map> +#include <set> +#include <ext/slist> + +int +main() +{ + std::string tem; + std::string str = "zardoz"; +// { dg-final { note-test str "\"zardoz\"" } } + + std::bitset<10> bs; + bs[0] = 1; + bs[5] = 1; + bs[7] = 1; +// { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } } + + std::deque<std::string> deq; + deq.push_back("one"); + deq.push_back("two"); +// { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } } + + std::deque<std::string>::iterator deqiter = deq.begin(); +// { dg-final { note-test deqiter {"one"} } } + + std::list<std::string> lst; + lst.push_back("one"); + lst.push_back("two"); +// { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } } + + std::list<std::string>::iterator lstiter = lst.begin(); + tem = *lstiter; +// { dg-final { note-test lstiter {"one"}} } + + std::list<std::string>::const_iterator lstciter = lst.begin(); + tem = *lstciter; +// { dg-final { note-test lstciter {"one"}} } + + std::map<std::string, int> mp; + mp["zardoz"] = 23; +// { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } } + + std::map<std::string, int>::iterator mpiter = mp.begin(); +// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } } + + std::set<std::string> sp; + sp.insert("clownfish"); + sp.insert("barrel"); +// { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } } + + std::set<std::string>::const_iterator spciter = sp.begin(); +// { dg-final { note-test spciter {"barrel"} } } + + __gnu_cxx::slist<int> sll; + sll.push_front(23); + sll.push_front(47); +// { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } } + + __gnu_cxx::slist<int>::iterator slliter = sll.begin(); +// { dg-final { note-test slliter {47} } } + + return 0; // Mark SPOT +} + +// { dg-final { gdb-test SPOT } } |