From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fencepost.gnu.org (fencepost.gnu.org [IPv6:2001:470:142:3::e]) by sourceware.org (Postfix) with ESMTPS id EF239395541E; Mon, 14 Jun 2021 18:11:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EF239395541E Received: from pool-96-233-64-159.bstnma.fios.verizon.net ([96.233.64.159]:58482 helo=pdslaptop.home.arpa) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsr41-0006VW-EB; Mon, 14 Jun 2021 14:11:57 -0400 Message-ID: <7b379a4f9c7dd9b111691d5b6b39c1dec24185af.camel@gnu.org> Subject: [PATCH 1/2] libstdc++: Count pretty-printed tuple elements from 0 not 1 From: Paul Smith Reply-To: psmith@gnu.org To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Date: Mon, 14 Jun 2021 14:11:56 -0400 Organization: GNU's Not UNIX! Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2021 18:11:59 -0000 Show 0-based offsets for std::tuple members, to match with std::get. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdTuplePrinter): don't increment self.count until after generating the result string. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 550e0ecdd22..14a6d998690 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -560,16 +560,17 @@ class StdTuplePrinter: # Process left node and set it as head. self.head = self.head.cast (nodes[0].type) - self.count = self.count + 1 - # Finally, check the implementation. If it is # wrapped in _M_head_impl return that, otherwise return # the value "as is". fields = impl.type.fields () - if len (fields) < 1 or fields[0].name != "_M_head_impl": - return ('[%d]' % self.count, impl) - else: - return ('[%d]' % self.count, impl['_M_head_impl']) + if len (fields) > 0 and fields[0].name == "_M_head_impl": + impl = impl['_M_head_impl'] + + out = '[%d]' % self.count + self.count = self.count + 1 + + return (out, impl) def __init__ (self, typename, val): self.typename = strip_versioned_namespace(typename) -- 2.28.0