From patchwork Fri Feb 20 14:40:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 441992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FA6140293 for ; Sat, 21 Feb 2015 01:40:38 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=WI8jRX1yvYRHjLTeRiVIQtOhzYenARFsddcGvyXYwF+e3NyRhVtWr pXMx0sK00UeMcW+Cpr4xc6/pVe5N7tRq+sDIQ6bgttjO8dj3DEVFWvBgwY2lHYTA AMxEmMvcT0G1VjuBFGVxJSY7+D4BTXLc6jR7O8Xeemk4cpewj9qtC0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=VEDj7RBsOI+n8EUnRu0KMf5IyKg=; b=cSiGqlF+Rws+1ve8BfIf w1LXwQXJ1B71s8ISGXbhgZxWqP1EZcrpXOgifcJd9fZW45n2Rn39tJzZrSk6qM+v zyEGK/qPlzZSti7dMF7sTbDqZNhSXWkw0Jbe/K2+QyX1iYElpoBWjp8CweubOc6e XAh69bJgy0Aq7XEueAhGAt4= Received: (qmail 23414 invoked by alias); 20 Feb 2015 14:40:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 23384 invoked by uid 89); 20 Feb 2015 14:40:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 20 Feb 2015 14:40:26 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1KEePFE028056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Feb 2015 09:40:25 -0500 Received: from localhost (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1KEeOaO030019; Fri, 20 Feb 2015 09:40:24 -0500 Date: Fri, 20 Feb 2015 14:40:23 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] libstdc++/64695 fix Pythin printer for std::tuple Message-ID: <20150220144023.GS3360@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This updates the Python printers to work with the new std::tuple layout as well as the old one (I changed std::tuple for GCC 5 to remove the empty base class that every tuple derived from). Tested x86_64-linux, committed to trunk. commit 5b522ed478febde4220e0e75bb84a0189bea5941 Author: Jonathan Wakely Date: Fri Feb 20 14:14:42 2015 +0000 PR libstdc++/64695 * python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle new tuple layout. diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 1263183..5a414c5 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -327,22 +327,35 @@ class StdTuplePrinter: return self def __next__ (self): - nodes = self.head.type.fields () # Check for further recursions in the inheritance tree. + # For a GCC 5+ tuple self.head is None after visiting all nodes: + if not self.head: + raise StopIteration + nodes = self.head.type.fields () + # For a GCC 4.x tuple there is a final node with no fields: if len (nodes) == 0: raise StopIteration # Check that this iteration has an expected structure. - if len (nodes) != 2: + if len (nodes) > 2: raise ValueError("Cannot parse more than 2 nodes in a tuple tree.") - # - Left node is the next recursion parent. - # - Right node is the actual class contained in the tuple. + if len (nodes) == 1: + # This is the last node of a GCC 5+ std::tuple. + impl = self.head.cast (nodes[0].type) + self.head = None + else: + # Either a node before the last node, or the last node of + # a GCC 4.x tuple (which has an empty parent). + + # - Left node is the next recursion parent. + # - Right node is the actual class contained in the tuple. - # Process right node. - impl = self.head.cast (nodes[1].type) + # Process right node. + impl = self.head.cast (nodes[1].type) + + # Process left node and set it as head. + self.head = self.head.cast (nodes[0].type) - # 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