From: Martin Sebor Date: Fri, 23 Nov 2018 16:12:03 +0000 (+0000) Subject: PR libstdc++/65229 fix pretty printer for std::bitset<0> X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14a9206d0c7c72a4df645e340cf12bfbaa1b1115;p=gcc.git PR libstdc++/65229 fix pretty printer for std::bitset<0> 2018-11-23 Martin Sebor Jonathan Wakely PR libstdc++/65229 * python/libstdcxx/v6/printers.py (StdBitsetPrinter): Handle exception thrown for std::bitset<0>. * testsuite/libstdc++-prettyprinters/simple.cc: Test std::bitset<0>. Co-Authored-By: Jonathan Wakely From-SVN: r266409 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2d86cc3efb4..6898733042d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2018-11-23 Martin Sebor + Jonathan Wakely + + PR libstdc++/65229 + * python/libstdcxx/v6/printers.py (StdBitsetPrinter): Handle + exception thrown for std::bitset<0>. + * testsuite/libstdc++-prettyprinters/simple.cc: Test std::bitset<0>. + 2018-11-23 Jonathan Wakely PR libstdc++/87308 (partial) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 28733385dc9..7c3c9d00ef3 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -702,7 +702,13 @@ class StdBitsetPrinter: return '%s' % (self.typename) def children (self): - words = self.val['_M_w'] + try: + # An empty bitset may not have any members which will + # result in an exception being thrown. + words = self.val['_M_w'] + except: + return [] + wtype = words.type # The _M_w member can be either an unsigned long, or an @@ -712,7 +718,7 @@ class StdBitsetPrinter: tsize = wtype.target ().sizeof else: words = [words] - tsize = wtype.sizeof + tsize = wtype.sizeof nwords = wtype.sizeof / tsize result = [] @@ -848,7 +854,7 @@ class Tr1HashtableIterator(Iterator): self.node = self.buckets[self.bucket] if self.node: break - self.bucket = self.bucket + 1 + self.bucket = self.bucket + 1 def __iter__ (self): return self @@ -951,7 +957,6 @@ class Tr1UnorderedMapPrinter: data = self.flatten (imap (self.format_one, StdHashtableIterator (self.hashtable()))) # Zip the two iterators together. return izip (counter, data) - def display_hint (self): return 'map' diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index 1ed8184a853..088c65dfe48 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -41,6 +41,10 @@ main() std::string str = "zardoz"; // { dg-final { note-test str "\"zardoz\"" } } + // PR 65229 + std::bitset<0> bs0; +// { dg-final { note-test bs0 {std::bitset} } } + std::bitset<10> bs; bs[0] = 1; bs[5] = 1;