From patchwork Wed Aug 18 14:36:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1518060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=dlfPMAt5; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GqVsP0spLz9sSs for ; Thu, 19 Aug 2021 00:39:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF7A3388F026 for ; Wed, 18 Aug 2021 14:39:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF7A3388F026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1629297557; bh=Nrf6OHpvX7c9uRA2Q6Cl21cVTQF6l44aV4DTvVToek0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dlfPMAt5H88HD0VDMix6w2yo2m3E5ZVbivXSdp453NMH4dNiIWv/LbnoypPsg9UY0 BWujvpDpGRBRT8NYMn/FN3pbq9nOfv7z4AwAJh8Ens9G7fIgQQrO6UHItugWCV1N0q +UBvClm8Wd/cXXF3dY1KBUgYwmsPRmq5jMSpyfpA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1DBDB385C41F for ; Wed, 18 Aug 2021 14:36:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1DBDB385C41F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-0h2cjJKPO8m8RRtY-JUBmw-1; Wed, 18 Aug 2021 10:36:29 -0400 X-MC-Unique: 0h2cjJKPO8m8RRtY-JUBmw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E61B1190B2A0; Wed, 18 Aug 2021 14:36:27 +0000 (UTC) Received: from localhost (unknown [10.33.36.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 763C56A056; Wed, 18 Aug 2021 14:36:27 +0000 (UTC) Date: Wed, 18 Aug 2021 15:36:26 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix vector printer tests to work in debug mode Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This fixes a compilation error in debug mode, due to std::_Bit_reference not being defined, because it's in namespace std::__cxx1998 instead. We can refer to it as vector::reference instead, which always works. That fixes some compilation errors in debug mode, but the tests fail at run-time instead because the printers for vector helpers are only registered for the std namespace, not std::__cxx1998. That is fixed by using add_container to register the printers instead of add_version, as the former registers them in the std and std::__cxx1998 namespaces. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdBitReferencePrinter): Use 'std::vector::reference' as type name, not _Bit_reference. (build_libstdcxx_dictionary): Register printers for vector types in debug mode too. * testsuite/libstdc++-prettyprinters/simple.cc: Adjust expected output for invalid _Bit_reference. Use vector::reference instead of _Bit_reference. * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise. Tested powerpc64le-linux. Committed to trunk. commit c883d1dcdea8820015ee7ffdc68c03cf3b8180bf Author: Jonathan Wakely Date: Tue Aug 17 15:06:22 2021 libstdc++: Fix vector printer tests to work in debug mode This fixes a compilation error in debug mode, due to std::_Bit_reference not being defined, because it's in namespace std::__cxx1998 instead. We can refer to it as vector::reference instead, which always works. That fixes some compilation errors in debug mode, but the tests fail at run-time instead because the printers for vector helpers are only registered for the std namespace, not std::__cxx1998. That is fixed by using add_container to register the printers instead of add_version, as the former registers them in the std and std::__cxx1998 namespaces. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdBitReferencePrinter): Use 'std::vector::reference' as type name, not _Bit_reference. (build_libstdcxx_dictionary): Register printers for vector types in debug mode too. * testsuite/libstdc++-prettyprinters/simple.cc: Adjust expected output for invalid _Bit_reference. Use vector::reference instead of _Bit_reference. * 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 82d262de8c7..c7da4079a7d 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -491,14 +491,14 @@ class StdBitIteratorPrinter: return bool(self.val['_M_p'].dereference() & (1 << self.val['_M_offset'])) class StdBitReferencePrinter: - "Print std::_Bit_reference" + "Print std::vector::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 'invalid std::vector::reference' return bool(self.val['_M_p'].dereference() & (self.val['_M_mask'])) class StdTuplePrinter: @@ -2052,11 +2052,11 @@ def build_libstdcxx_dictionary (): StdDequeIteratorPrinter) libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator', StdVectorIteratorPrinter) - libstdcxx_printer.add_version('std::', '_Bit_iterator', + libstdcxx_printer.add_container('std::', '_Bit_iterator', StdBitIteratorPrinter) - libstdcxx_printer.add_version('std::', '_Bit_const_iterator', + libstdcxx_printer.add_container('std::', '_Bit_const_iterator', StdBitIteratorPrinter) - libstdcxx_printer.add_version('std::', '_Bit_reference', + libstdcxx_printer.add_container('std::', '_Bit_reference', StdBitReferencePrinter) libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator', StdSlistIteratorPrinter) diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index c1fc4b1fe72..02f762efe28 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -144,19 +144,19 @@ main() std::vector::iterator vbIt0; // { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector} } } - std::_Bit_reference br = *vb.begin(); + std::vector::reference br = *vb.begin(); // { dg-final { note-test br {true} } } - std::_Bit_reference br2 = *vbIt2; + std::vector::reference br2 = *vbIt2; // { dg-final { note-test br2 {true} } } - std::_Bit_reference br3 = *vbIt3; + std::vector::reference br3 = *vbIt3; // { dg-final { note-test br3 {false} } } - std::_Bit_reference br4 = *vbIt4; + std::vector::reference br4 = *vbIt4; // { dg-final { note-test br4 {false} } } - std::_Bit_reference br5 = *vbIt5; + std::vector::reference br5 = *vbIt5; // { dg-final { note-test br5 {true} } } - std::_Bit_reference br0; -// { dg-final { note-test br0 {invalid std::_Bit_reference} } } + std::vector::reference br0; +// { dg-final { note-test br0 {invalid std::vector::reference} } } __gnu_cxx::slist sll; sll.push_front(23); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc index d219e271ff3..bd6e026a329 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc @@ -137,19 +137,19 @@ main() std::vector::iterator vbIt0; // { dg-final { note-test vbIt0 {non-dereferenceable iterator for std::vector} } } - std::_Bit_reference br = *vb.begin(); + std::vector::reference br = *vb.begin(); // { dg-final { note-test br {true} } } - std::_Bit_reference br2 = *vbIt2; + std::vector::reference br2 = *vbIt2; // { dg-final { note-test br2 {true} } } - std::_Bit_reference br3 = *vbIt3; + std::vector::reference br3 = *vbIt3; // { dg-final { note-test br3 {false} } } - std::_Bit_reference br4 = *vbIt4; + std::vector::reference br4 = *vbIt4; // { dg-final { note-test br4 {false} } } - std::_Bit_reference br5 = *vbIt5; + std::vector::reference br5 = *vbIt5; // { dg-final { note-test br5 {true} } } - std::_Bit_reference br0; -// { dg-final { note-test br0 {invalid std::_Bit_reference} } } + std::vector::reference br0; +// { dg-final { note-test br0 {invalid std::vector::reference} } } __gnu_cxx::slist sll; sll.push_front(23);