+2019-06-19 Michael Weghorn <m.weghorn@posteo.de>
+ Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/90945
+ * python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Use
+ values of type bool for vector<bool> elements.
+ * testsuite/libstdc++-prettyprinters/simple.cc: Test vector<bool>.
+ * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
+
2019-06-19 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/90920 partially revert r263433
if self.bitvec:
if self.item == self.finish and self.so >= self.fo:
raise StopIteration
- elt = self.item.dereference()
- if elt & (1 << self.so):
- obit = 1
- else:
- obit = 0
+ elt = bool(self.item.dereference() & (1 << self.so))
self.so = self.so + 1
if self.so >= self.isize:
self.item = self.item + 1
self.so = 0
- return ('[%d]' % count, obit)
+ return ('[%d]' % count, elt)
else:
if self.item == self.finish:
raise StopIteration
def __init__(self, typename, val):
self.typename = strip_versioned_namespace(typename)
self.val = val
- self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
+ self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
def children(self):
return self._iterator(self.val['_M_impl']['_M_start'],
return 'non-dereferenceable iterator for std::vector'
return str(self.val['_M_current'].dereference())
+# TODO add printer for vector<bool>'s _Bit_iterator and _Bit_const_iterator
+
class StdTuplePrinter:
"Print a std::tuple"
std::vector<int>::iterator viter0;
// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
+ std::vector<bool> vb;
+ vb.reserve(100);
+ vb.push_back(true);
+ vb.push_back(true);
+ vb.push_back(false);
+ vb.push_back(false);
+ vb.push_back(true);
+ vb.erase(vb.begin());
+// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 4, capacity 128 = \\{true, false, false, true\\}} } }
+
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);
std::vector<int>::iterator viter0;
// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
+ std::vector<bool> vb;
+ vb.reserve(100);
+ vb.push_back(true);
+ vb.push_back(true);
+ vb.push_back(false);
+ vb.push_back(false);
+ vb.push_back(true);
+ vb.erase(vb.begin());
+// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 4, capacity 128 = \\{true, false, false, true\\}} } }
+
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);