public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
@ 2020-09-14 14:49 Michael Weghorn
  2020-09-22 10:04 ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Weghorn @ 2020-09-14 14:49 UTC (permalink / raw)
  To: gcc-patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]

Hi,

the attached patch implements pretty printers relevant for iteration
over std::vector<bool>, thus handling the TODO
added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
("Have std::vector printer's iterator return bool for vector<bool>",
2019-06-19):

    TODO add printer for vector<bool>'s _Bit_iterator and
_Bit_const_iterator

Tested on x86_64-pc-linux-gnu (Debian testing).

I haven't filed any copyright assignment for GCC yet, but I'm happy to
do so when pointed to the right place.

Best regards,
Michael

[-- Attachment #2: 0001-libstdc-Pretty-printers-for-std-_Bit_reference-std-_.patch --]
[-- Type: text/x-patch, Size: 7000 bytes --]

From a279887aa80971acc2e92157550138eff6c2a4c8 Mon Sep 17 00:00:00 2001
From: Michael Weghorn <m.weghorn@posteo.de>
Date: Mon, 14 Sep 2020 15:20:36 +0200
Subject: [PATCH] libstdc++: Pretty printers for std::_Bit_reference,
 std::_Bit_iterator

... and 'std::_Bit_const_iterator'.

'std::_Bit_iterator' and 'std::_Bit_const_iterator' are the iterators
used by 'std::vector<bool>'.
'std::_Bit_reference' is e.g. used in range-based for loops over
'std::vector<bool>'  like

    std::vector<bool> vb {true, false, false};
    for (auto b : vb) {
        // b is of type std::_Bit_reference here
        // ...
    }

Like iterators of vectors for other types, the actual value is printed.

Add corresponding tests to the testsuite.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdBitIteratorPrinter,
	StdBitReferencePrinter): Add pretty-printers for
        std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator.
        * testsuite/libstdc++-prettyprinters/simple.cc: Test
        std::_Bit_reference, std::_Bit_iterator
        * testsuite/libstdc++-prettyprinters/simple11.cc: Test
        std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
---
 libstdc++-v3/python/libstdcxx/v6/printers.py  | 28 ++++++++++++++++-
 .../libstdc++-prettyprinters/simple.cc        | 28 +++++++++++++++++
 .../libstdc++-prettyprinters/simple11.cc      | 31 +++++++++++++++++++
 3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index c0f061f79c1..478e44eefdf 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -479,7 +479,27 @@ class StdVectorIteratorPrinter:
             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 StdBitIteratorPrinter:
+    "Print std::vector<bool>'s _Bit_iterator and _Bit_const_iterator"
+
+    def __init__(self, typename, val):
+        self.val = val
+
+    def to_string(self):
+        if not self.val['_M_p']:
+            return 'non-dereferenceable iterator for std::vector<bool>'
+        return bool(self.val['_M_p'].dereference() & (1 << self.val['_M_offset']))
+
+class StdBitReferencePrinter:
+    "Print std::_Bit_reference"
+
+    def __init__(self, typename, val):
+        self.val = val
+
+    def to_string(self):
+        if not self.val['_M_p']:
+            return 'invalid std::_Bit_reference'
+        return bool(self.val['_M_p'].dereference() & (self.val['_M_mask']))
 
 class StdTuplePrinter:
     "Print a std::tuple"
@@ -1965,6 +1985,12 @@ def build_libstdcxx_dictionary ():
                                         StdDequeIteratorPrinter)
         libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator',
                                       StdVectorIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_iterator',
+                                      StdBitIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_const_iterator',
+                                      StdBitIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_reference',
+                                      StdBitReferencePrinter)
         libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator',
                                       StdSlistIteratorPrinter)
         libstdcxx_printer.add_container('std::', '_Fwd_list_iterator',
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
index 4b44be594f5..4cfbb7857d1 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
@@ -127,6 +127,34 @@ main()
   vb.erase(vb.begin());
 // { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
 
+  std::vector<bool>::iterator vbIt = vb.begin();
+// { dg-final { note-test vbIt {true} } }
+  std::vector<bool>::iterator vbIt2 = ++vbIt;
+// { dg-final { note-test vbIt2 {true} } }
+  std::vector<bool>::iterator vbIt3 = ++vbIt;
+// { dg-final { note-test vbIt3 {false} } }
+  std::vector<bool>::iterator vbIt4 = ++vbIt;
+// { dg-final { note-test vbIt4 {false} } }
+  std::vector<bool>::iterator vbIt5 = ++vbIt;
+// { dg-final { note-test vbIt5 {true} } }
+
+  std::vector<bool>::iterator vbIt0;
+// { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector<bool>} } }
+
+  std::_Bit_reference br = *vb.begin();
+// { dg-final { note-test br {true} } }
+  std::_Bit_reference br2 = *vbIt2;
+// { dg-final { note-test br2 {true} } }
+  std::_Bit_reference br3 = *vbIt3;
+// { dg-final { note-test br3 {false} } }
+  std::_Bit_reference br4 = *vbIt4;
+// { dg-final { note-test br4 {false} } }
+  std::_Bit_reference br5 = *vbIt5;
+// { dg-final { note-test br5 {true} } }
+
+ std::_Bit_reference br0;
+// { dg-final { note-test br0 {invalid std::_Bit_reference} } }
+
   __gnu_cxx::slist<int> sll;
   sll.push_front(23);
   sll.push_front(47);
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
index 0ebd80a42e9..519565693b7 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
@@ -120,6 +120,37 @@ main()
   vb.erase(vb.begin());
 // { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
 
+  std::vector<bool>::iterator vbIt = vb.begin();
+// { dg-final { note-test vbIt {true} } }
+  std::vector<bool>::iterator vbIt2 = ++vbIt;
+// { dg-final { note-test vbIt2 {true} } }
+  std::vector<bool>::iterator vbIt3 = ++vbIt;
+// { dg-final { note-test vbIt3 {false} } }
+  std::vector<bool>::iterator vbIt4 = ++vbIt;
+// { dg-final { note-test vbIt4 {false} } }
+  std::vector<bool>::iterator vbIt5 = ++vbIt;
+// { dg-final { note-test vbIt5 {true} } }
+
+  std::vector<bool>::const_iterator vbcIt = vb.cbegin();
+// { dg-final { note-test vbcIt {true} } }
+
+  std::vector<bool>::iterator vbIt0;
+// { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector<bool>} } }
+
+  std::_Bit_reference br = *vb.begin();
+// { dg-final { note-test br {true} } }
+  std::_Bit_reference br2 = *vbIt2;
+// { dg-final { note-test br2 {true} } }
+  std::_Bit_reference br3 = *vbIt3;
+// { dg-final { note-test br3 {false} } }
+  std::_Bit_reference br4 = *vbIt4;
+// { dg-final { note-test br4 {false} } }
+  std::_Bit_reference br5 = *vbIt5;
+// { dg-final { note-test br5 {true} } }
+
+ std::_Bit_reference br0;
+// { dg-final { note-test br0 {invalid std::_Bit_reference} } }
+
   __gnu_cxx::slist<int> sll;
   sll.push_front(23);
   sll.push_front(47);
-- 
2.28.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-09-14 14:49 [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator Michael Weghorn
@ 2020-09-22 10:04 ` Jonathan Wakely
  2020-10-11 17:22   ` Michael Weghorn
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2020-09-22 10:04 UTC (permalink / raw)
  To: Michael Weghorn; +Cc: gcc-patches, libstdc++

On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>Hi,
>
>the attached patch implements pretty printers relevant for iteration
>over std::vector<bool>, thus handling the TODO
>added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>("Have std::vector printer's iterator return bool for vector<bool>",
>2019-06-19):
>
>    TODO add printer for vector<bool>'s _Bit_iterator and
>_Bit_const_iterator
>
>Tested on x86_64-pc-linux-gnu (Debian testing).
>
>I haven't filed any copyright assignment for GCC yet, but I'm happy to
>do so when pointed to the right place.

Thanks for the patch! I'll send you the form to start the copyuright
assignment process.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-09-22 10:04 ` Jonathan Wakely
@ 2020-10-11 17:22   ` Michael Weghorn
  2020-11-25 14:05     ` [PING] " Michael Weghorn
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Weghorn @ 2020-10-11 17:22 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches, libstdc++


[-- Attachment #1.1: Type: text/plain, Size: 882 bytes --]

On 22/09/2020 12.04, Jonathan Wakely wrote:
> On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>> Hi,
>>
>> the attached patch implements pretty printers relevant for iteration
>> over std::vector<bool>, thus handling the TODO
>> added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>> ("Have std::vector printer's iterator return bool for vector<bool>",
>> 2019-06-19):
>>
>>    TODO add printer for vector<bool>'s _Bit_iterator and
>> _Bit_const_iterator
>>
>> Tested on x86_64-pc-linux-gnu (Debian testing).
>>
>> I haven't filed any copyright assignment for GCC yet, but I'm happy to
>> do so when pointed to the right place.
> 
> Thanks for the patch! I'll send you the form to start the copyuright
> assignment process.
> 
> 

Thanks! The copyright assignment is done now. Is there anything else to
do from my side at the moment?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PING] [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-10-11 17:22   ` Michael Weghorn
@ 2020-11-25 14:05     ` Michael Weghorn
  2020-11-27 16:33       ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Weghorn @ 2020-11-25 14:05 UTC (permalink / raw)
  To: Michael Weghorn, Jonathan Wakely; +Cc: libstdc++, gcc-patches

I'd like to ping for this patch:
https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553870.html

Michael

On 11/10/2020 19.22, Michael Weghorn via Gcc-patches wrote:
> On 22/09/2020 12.04, Jonathan Wakely wrote:
>> On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>>> Hi,
>>>
>>> the attached patch implements pretty printers relevant for iteration
>>> over std::vector<bool>, thus handling the TODO
>>> added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>>> ("Have std::vector printer's iterator return bool for vector<bool>",
>>> 2019-06-19):
>>>
>>>     TODO add printer for vector<bool>'s _Bit_iterator and
>>> _Bit_const_iterator
>>>
>>> Tested on x86_64-pc-linux-gnu (Debian testing).
>>>
>>> I haven't filed any copyright assignment for GCC yet, but I'm happy to
>>> do so when pointed to the right place.
>>
>> Thanks for the patch! I'll send you the form to start the copyuright
>> assignment process.
>>
>>
> 
> Thanks! The copyright assignment is done now. Is there anything else to
> do from my side at the moment?
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PING] [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-11-25 14:05     ` [PING] " Michael Weghorn
@ 2020-11-27 16:33       ` Jonathan Wakely
  2020-12-01 21:37         ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2020-11-27 16:33 UTC (permalink / raw)
  To: Michael Weghorn; +Cc: libstdc++, gcc-patches

On 25/11/20 15:05 +0100, Michael Weghorn via Libstdc++ wrote:
>I'd like to ping for this patch:
>https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553870.html

Thanks, I'll take another look next week.


>Michael
>
>On 11/10/2020 19.22, Michael Weghorn via Gcc-patches wrote:
>>On 22/09/2020 12.04, Jonathan Wakely wrote:
>>>On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>>>>Hi,
>>>>
>>>>the attached patch implements pretty printers relevant for iteration
>>>>over std::vector<bool>, thus handling the TODO
>>>>added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>>>>("Have std::vector printer's iterator return bool for vector<bool>",
>>>>2019-06-19):
>>>>
>>>>    TODO add printer for vector<bool>'s _Bit_iterator and
>>>>_Bit_const_iterator
>>>>
>>>>Tested on x86_64-pc-linux-gnu (Debian testing).
>>>>
>>>>I haven't filed any copyright assignment for GCC yet, but I'm happy to
>>>>do so when pointed to the right place.
>>>
>>>Thanks for the patch! I'll send you the form to start the copyuright
>>>assignment process.
>>>
>>>
>>
>>Thanks! The copyright assignment is done now. Is there anything else to
>>do from my side at the moment?
>>
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PING] [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-11-27 16:33       ` Jonathan Wakely
@ 2020-12-01 21:37         ` Jonathan Wakely
  2020-12-02  7:01           ` Michael Weghorn
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2020-12-01 21:37 UTC (permalink / raw)
  To: Michael Weghorn; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

On 27/11/20 16:33 +0000, Jonathan Wakely wrote:
>On 25/11/20 15:05 +0100, Michael Weghorn via Libstdc++ wrote:
>>I'd like to ping for this patch:
>>https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553870.html
>
>Thanks, I'll take another look next week.

I've applied the patch now, thanks.

I adjusted it slightly, to add a test for const_iterator to the C++98
test, simple.cc, consistent with the C++11 one, simple11.cc

Tested powerpc64le-linux, committed to trunk.

Thanks again for the patch, and your patience.


>>Michael
>>
>>On 11/10/2020 19.22, Michael Weghorn via Gcc-patches wrote:
>>>On 22/09/2020 12.04, Jonathan Wakely wrote:
>>>>On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>>>>>Hi,
>>>>>
>>>>>the attached patch implements pretty printers relevant for iteration
>>>>>over std::vector<bool>, thus handling the TODO
>>>>>added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>>>>>("Have std::vector printer's iterator return bool for vector<bool>",
>>>>>2019-06-19):
>>>>>
>>>>>   TODO add printer for vector<bool>'s _Bit_iterator and
>>>>>_Bit_const_iterator
>>>>>
>>>>>Tested on x86_64-pc-linux-gnu (Debian testing).
>>>>>
>>>>>I haven't filed any copyright assignment for GCC yet, but I'm happy to
>>>>>do so when pointed to the right place.
>>>>
>>>>Thanks for the patch! I'll send you the form to start the copyuright
>>>>assignment process.
>>>>
>>>>
>>>
>>>Thanks! The copyright assignment is done now. Is there anything else to
>>>do from my side at the moment?
>>>
>>

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 6756 bytes --]

commit 39836f8324d819459cb21198e95b993588c6a2b1
Author: Michael Weghorn <m.weghorn@posteo.de>
Date:   Tue Dec 1 21:19:20 2020

    libstdc++: Pretty printers for _Bit_reference and _Bit_iterator
    
    'std::_Bit_iterator' and 'std::_Bit_const_iterator' are the iterators
    used by 'std::vector<bool>'.
    'std::_Bit_reference' is e.g. used in range-based for loops over
    'std::vector<bool>'  like
    
        std::vector<bool> vb {true, false, false};
        for (auto b : vb) {
            // b is of type std::_Bit_reference here
            // ...
        }
    
    Like iterators of vectors for other types, the actual value is printed.
    
    libstdc++-v3/ChangeLog:
    
            * python/libstdcxx/v6/printers.py (StdBitIteratorPrinter)
            (StdBitReferencePrinter): Add pretty-printers for
            _Bit_reference, _Bit_iterator and _Bit_const_iterator.
            * testsuite/libstdc++-prettyprinters/simple.cc: Test
            std::_Bit_reference, std::_Bit_iterator and
            std::_Bit_const_iterator.
            * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index c0f061f79c1..478e44eefdf 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -479,7 +479,27 @@ class StdVectorIteratorPrinter:
             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 StdBitIteratorPrinter:
+    "Print std::vector<bool>'s _Bit_iterator and _Bit_const_iterator"
+
+    def __init__(self, typename, val):
+        self.val = val
+
+    def to_string(self):
+        if not self.val['_M_p']:
+            return 'non-dereferenceable iterator for std::vector<bool>'
+        return bool(self.val['_M_p'].dereference() & (1 << self.val['_M_offset']))
+
+class StdBitReferencePrinter:
+    "Print std::_Bit_reference"
+
+    def __init__(self, typename, val):
+        self.val = val
+
+    def to_string(self):
+        if not self.val['_M_p']:
+            return 'invalid std::_Bit_reference'
+        return bool(self.val['_M_p'].dereference() & (self.val['_M_mask']))
 
 class StdTuplePrinter:
     "Print a std::tuple"
@@ -1965,6 +1985,12 @@ def build_libstdcxx_dictionary ():
                                         StdDequeIteratorPrinter)
         libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator',
                                       StdVectorIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_iterator',
+                                      StdBitIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_const_iterator',
+                                      StdBitIteratorPrinter)
+        libstdcxx_printer.add_version('std::', '_Bit_reference',
+                                      StdBitReferencePrinter)
         libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator',
                                       StdSlistIteratorPrinter)
         libstdcxx_printer.add_container('std::', '_Fwd_list_iterator',
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
index 4b44be594f5..9821d1805cf 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
@@ -127,6 +127,37 @@ main()
   vb.erase(vb.begin());
 // { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
 
+  std::vector<bool>::iterator vbIt = vb.begin();
+// { dg-final { note-test vbIt {true} } }
+  std::vector<bool>::iterator vbIt2 = ++vbIt;
+// { dg-final { note-test vbIt2 {true} } }
+  std::vector<bool>::iterator vbIt3 = ++vbIt;
+// { dg-final { note-test vbIt3 {false} } }
+  std::vector<bool>::iterator vbIt4 = ++vbIt;
+// { dg-final { note-test vbIt4 {false} } }
+  std::vector<bool>::iterator vbIt5 = ++vbIt;
+// { dg-final { note-test vbIt5 {true} } }
+
+  std::vector<bool>::const_iterator vbcIt = vb.begin();
+// { dg-final { note-test vbcIt {true} } }
+
+  std::vector<bool>::iterator vbIt0;
+// { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector<bool>} } }
+
+  std::_Bit_reference br = *vb.begin();
+// { dg-final { note-test br {true} } }
+  std::_Bit_reference br2 = *vbIt2;
+// { dg-final { note-test br2 {true} } }
+  std::_Bit_reference br3 = *vbIt3;
+// { dg-final { note-test br3 {false} } }
+  std::_Bit_reference br4 = *vbIt4;
+// { dg-final { note-test br4 {false} } }
+  std::_Bit_reference br5 = *vbIt5;
+// { dg-final { note-test br5 {true} } }
+
+ std::_Bit_reference br0;
+// { dg-final { note-test br0 {invalid std::_Bit_reference} } }
+
   __gnu_cxx::slist<int> sll;
   sll.push_front(23);
   sll.push_front(47);
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
index 0ebd80a42e9..519565693b7 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
@@ -120,6 +120,37 @@ main()
   vb.erase(vb.begin());
 // { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
 
+  std::vector<bool>::iterator vbIt = vb.begin();
+// { dg-final { note-test vbIt {true} } }
+  std::vector<bool>::iterator vbIt2 = ++vbIt;
+// { dg-final { note-test vbIt2 {true} } }
+  std::vector<bool>::iterator vbIt3 = ++vbIt;
+// { dg-final { note-test vbIt3 {false} } }
+  std::vector<bool>::iterator vbIt4 = ++vbIt;
+// { dg-final { note-test vbIt4 {false} } }
+  std::vector<bool>::iterator vbIt5 = ++vbIt;
+// { dg-final { note-test vbIt5 {true} } }
+
+  std::vector<bool>::const_iterator vbcIt = vb.cbegin();
+// { dg-final { note-test vbcIt {true} } }
+
+  std::vector<bool>::iterator vbIt0;
+// { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector<bool>} } }
+
+  std::_Bit_reference br = *vb.begin();
+// { dg-final { note-test br {true} } }
+  std::_Bit_reference br2 = *vbIt2;
+// { dg-final { note-test br2 {true} } }
+  std::_Bit_reference br3 = *vbIt3;
+// { dg-final { note-test br3 {false} } }
+  std::_Bit_reference br4 = *vbIt4;
+// { dg-final { note-test br4 {false} } }
+  std::_Bit_reference br5 = *vbIt5;
+// { dg-final { note-test br5 {true} } }
+
+ std::_Bit_reference br0;
+// { dg-final { note-test br0 {invalid std::_Bit_reference} } }
+
   __gnu_cxx::slist<int> sll;
   sll.push_front(23);
   sll.push_front(47);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PING] [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator
  2020-12-01 21:37         ` Jonathan Wakely
@ 2020-12-02  7:01           ` Michael Weghorn
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Weghorn @ 2020-12-02  7:01 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On 01/12/2020 22.37, Jonathan Wakely wrote:
> On 27/11/20 16:33 +0000, Jonathan Wakely wrote:
>> On 25/11/20 15:05 +0100, Michael Weghorn via Libstdc++ wrote:
>>> I'd like to ping for this patch:
>>> https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553870.html
>>
>> Thanks, I'll take another look next week.
> 
> I've applied the patch now, thanks.
> 
> I adjusted it slightly, to add a test for const_iterator to the C++98
> test, simple.cc, consistent with the C++11 one, simple11.cc

Thanks!

> 
> Tested powerpc64le-linux, committed to trunk.
> 
> Thanks again for the patch, and your patience.
> 
> 
>>> Michael
>>>
>>> On 11/10/2020 19.22, Michael Weghorn via Gcc-patches wrote:
>>>> On 22/09/2020 12.04, Jonathan Wakely wrote:
>>>>> On 14/09/20 16:49 +0200, Michael Weghorn via Libstdc++ wrote:
>>>>>> Hi,
>>>>>>
>>>>>> the attached patch implements pretty printers relevant for iteration
>>>>>> over std::vector<bool>, thus handling the TODO
>>>>>> added in commit 36d0dada6773d7fd7c5ace64c90e723930a3b81e
>>>>>> ("Have std::vector printer's iterator return bool for vector<bool>",
>>>>>> 2019-06-19):
>>>>>>
>>>>>>    TODO add printer for vector<bool>'s _Bit_iterator and
>>>>>> _Bit_const_iterator
>>>>>>
>>>>>> Tested on x86_64-pc-linux-gnu (Debian testing).
>>>>>>
>>>>>> I haven't filed any copyright assignment for GCC yet, but I'm 
>>>>>> happy to
>>>>>> do so when pointed to the right place.
>>>>>
>>>>> Thanks for the patch! I'll send you the form to start the copyuright
>>>>> assignment process.
>>>>>
>>>>>
>>>>
>>>> Thanks! The copyright assignment is done now. Is there anything else to
>>>> do from my side at the moment?
>>>>
>>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-02  7:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 14:49 [PATCH] libstdc++: Pretty printers for std::_Bit_reference, std::_Bit_iterator and std::_Bit_const_iterator Michael Weghorn
2020-09-22 10:04 ` Jonathan Wakely
2020-10-11 17:22   ` Michael Weghorn
2020-11-25 14:05     ` [PING] " Michael Weghorn
2020-11-27 16:33       ` Jonathan Wakely
2020-12-01 21:37         ` Jonathan Wakely
2020-12-02  7:01           ` Michael Weghorn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).