2016-12-15 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/59170
+ * python/libstdcxx/v6/printers.py (StdListIteratorPrinter.to_string)
+ (StdSlistIteratorPrinter.to_string, StdVectorIteratorPrinter.to_string)
+ (StdRbtreeIteratorPrinter.to_string)
+ (StdDequeIteratorPrinter.to_string): Add check for value-initialized
+ iterators.
+ * testsuite/libstdc++-prettyprinters/simple.cc: Test them.
+ * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
+
PR libstdc++/59161
* python/libstdcxx/v6/printers.py (StdListIteratorPrinter.to_string)
(StdSlistIteratorPrinter.to_string, StdVectorIteratorPrinter.to_string)
self.typename = typename
def to_string(self):
+ if not self.val['_M_node']:
+ return 'non-dereferenceable iterator for std::list'
nodetype = find_type(self.val.type, '_Node')
nodetype = nodetype.strip_typedefs().pointer()
node = self.val['_M_node'].cast(nodetype).dereference()
self.val = val
def to_string(self):
+ if not self.val['_M_node']:
+ return 'non-dereferenceable iterator for __gnu_cxx::slist'
nodetype = find_type(self.val.type, '_Node')
nodetype = nodetype.strip_typedefs().pointer()
return str(self.val['_M_node'].cast(nodetype).dereference()['_M_data'])
self.val = val
def to_string(self):
+ if not self.val['_M_current']:
+ return 'non-dereferenceable iterator for std::vector'
return str(self.val['_M_current'].dereference())
class StdTuplePrinter:
self.link_type = nodetype.strip_typedefs().pointer()
def to_string (self):
+ if not self.val['_M_node']:
+ return 'non-dereferenceable iterator for associative container'
node = self.val['_M_node'].cast(self.link_type).dereference()
return str(get_value_from_Rb_tree_node(node))
self.val = val
def to_string(self):
+ if not self.val['_M_cur']:
+ return 'non-dereferenceable iterator for std::deque'
return str(self.val['_M_cur'].dereference())
class StdStringPrinter:
#include <list>
#include <map>
#include <set>
+#include <vector>
#include <ext/slist>
int
deq.push_back("two");
// { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } }
+ std::deque<int>::iterator deqiter0;
+// { dg-final { note-test deqiter0 {non-dereferenceable iterator for std::deque} } }
+
std::deque<std::string>::iterator deqiter = deq.begin();
// { dg-final { note-test deqiter {"one"} } }
lst.push_back("two");
// { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
+ std::list<int>::iterator lstiter0;
+// { dg-final { note-test lstiter0 {non-dereferenceable iterator for std::list} } }
+
std::list<std::string>::iterator lstiter = lst.begin();
tem = *lstiter;
// { dg-final { note-test lstiter {"one"}} }
std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
+ std::map<std::string, int>::iterator mpiter0;
+// { dg-final { note-test mpiter0 {non-dereferenceable iterator for associative container} } }
+
// PR 67440
std::set<int> intset;
intset.insert(2);
std::set<std::string>::const_iterator spciter = sp.begin();
// { dg-final { note-test spciter {"barrel"} } }
+ std::set<int>::iterator spiter0;
+// { dg-final { note-test spiter0 {non-dereferenceable iterator for associative container} } }
+
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ v.erase(v.begin());
+// { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
+ std::vector<int>::iterator viter3 = v.begin();
+// { dg-final { note-test viter3 {2} } }
+
+ std::vector<int>::iterator viter0;
+// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
+
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);
__gnu_cxx::slist<int>::iterator slliter = sll.begin();
// { dg-final { note-test slliter {47} } }
+ __gnu_cxx::slist<int>::iterator slliter0;
+// { dg-final { note-test slliter0 {non-dereferenceable iterator for __gnu_cxx::slist} } }
+
std::cout << "\n";
return 0; // Mark SPOT
}
#include <list>
#include <map>
#include <set>
+#include <vector>
#include <ext/slist>
int
std::deque<std::string>::iterator deqiter = deq.begin();
// { dg-final { note-test deqiter {"one"} } }
+ std::deque<int>::iterator deqiter0;
+// { dg-final { note-test deqiter0 {non-dereferenceable iterator for std::deque} } }
+
std::list<std::string> lst;
lst.push_back("one");
lst.push_back("two");
tem = *lstciter;
// { dg-final { note-test lstciter {"one"}} }
+ std::list<int>::iterator lstiter0;
+// { dg-final { note-test lstiter0 {non-dereferenceable iterator for std::list} } }
+
std::map<std::string, int> mp;
mp["zardoz"] = 23;
// { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
+ std::map<std::string, int>::iterator mpiter0;
+// { dg-final { note-test mpiter0 {non-dereferenceable iterator for associative container} } }
+
// PR 67440
const std::set<int> const_intset = {2, 3};
// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
std::set<std::string>::const_iterator spciter = sp.begin();
// { dg-final { note-test spciter {"barrel"} } }
+ std::set<int>::iterator spiter0;
+// { dg-final { note-test spiter0 {non-dereferenceable iterator for associative container} } }
+
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ v.erase(v.begin());
+// { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
+ std::vector<int>::iterator viter3 = v.begin();
+// { dg-final { note-test viter3 {2} } }
+
+ std::vector<int>::iterator viter0;
+// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
+
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);
__gnu_cxx::slist<int>::iterator slliter = sll.begin();
// { dg-final { note-test slliter {47} } }
+ __gnu_cxx::slist<int>::iterator slliter0;
+// { dg-final { note-test slliter0 {non-dereferenceable iterator for __gnu_cxx::slist} } }
+
std::cout << "\n";
return 0; // Mark SPOT
}