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 A132F385782D for ; Sun, 13 Jun 2021 16:34:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A132F385782D Received: from pool-96-233-64-159.bstnma.fios.verizon.net ([96.233.64.159]:43858 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 1lsT49-0001rn-KM for gcc@gcc.gnu.org; Sun, 13 Jun 2021 12:34:29 -0400 Message-ID: Subject: [PATCH 1/2] libstdc++: Count pretty-printed tuple elements from 0 not 1 From: Paul Smith Reply-To: psmith@gnu.org To: "gcc@gcc.gnu.org" Date: Sun, 13 Jun 2021 12:34:28 -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=-8.5 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: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2021 16:34:31 -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