aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-12-15 14:13:36 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2016-12-15 14:13:36 +0000
commitbdfc9f5c544ba44e0a5b892c3a5976d139261158 (patch)
treee0c4334f0da476def753f05ddcaa1936ba9c0289 /libstdc++-v3/python
parentfec5ce248546144be3bec8655fd72c091c813594 (diff)
downloadgcc-bdfc9f5c544ba44e0a5b892c3a5976d139261158.zip
gcc-bdfc9f5c544ba44e0a5b892c3a5976d139261158.tar.gz
gcc-bdfc9f5c544ba44e0a5b892c3a5976d139261158.tar.bz2
PR59170 make pretty printers check for singular iterators
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. From-SVN: r243692
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index ab3592a..86de1ca 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -200,6 +200,8 @@ class StdListIteratorPrinter:
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()
@@ -246,6 +248,8 @@ class StdSlistIteratorPrinter:
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'])
@@ -333,6 +337,8 @@ class StdVectorIteratorPrinter:
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:
@@ -494,6 +500,8 @@ class StdRbtreeIteratorPrinter:
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))
@@ -708,6 +716,8 @@ class StdDequeIteratorPrinter:
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: