From patchwork Wed May 25 19:45:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97407 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]) by ozlabs.org (Postfix) with SMTP id F29D3B6F98 for ; Thu, 26 May 2011 05:46:05 +1000 (EST) Received: (qmail 15028 invoked by alias); 25 May 2011 19:46:03 -0000 Received: (qmail 15020 invoked by uid 22791); 25 May 2011 19:46:02 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 May 2011 19:45:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4PJjlMP009293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 May 2011 15:45:47 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4PJjlEg011985 for ; Wed, 25 May 2011 15:45:47 -0400 Message-ID: <4DDD5C6A.4030405@redhat.com> Date: Wed, 25 May 2011 15:45:46 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/45698 (crash with variadics) 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 45698 was actually fixed in 4.5.0, but before I closed it I checked to see how the testcase was doing with the current compiler, and found that it was crashing again. This turned out to be because of Nathan's recent tree-slimming work; ARGUMENT_PACK_SELECT doesn't have TREE_TYPE, so we crash when we try to look at it in value_dependent_expression_p. But we shouldn't be treating it as an expression in the first place, since it could be either a type or value argument. Fixed by looking through ARGUMENT_PACK_SELECT before we decide what sort of template argument we're dealing with. While looking at this, I also noticed that print_node expects everything to have TREE_TYPE, which is no longer correct. And I made print_node more useful for ARGUMENT_PACK_SELECT. Tested x86_64-pc-linux-gnu, applying to trunk. commit 46cccd60afea40407a278f6d937373e0121c24ee Author: Jason Merrill Date: Wed May 25 13:32:05 2011 -0400 * print-tree.c (print_node): Only look at TREE_TYPE if TS_TYPED. * cp/ptree.c (cxx_print_xnode): Handle ARGUMENT_PACK_SELECT. diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index a4c3ed5..5c9626e 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -221,6 +221,12 @@ cxx_print_xnode (FILE *file, tree node, int indent) fprintf (file, "pending_template"); } break; + case ARGUMENT_PACK_SELECT: + print_node (file, "pack", ARGUMENT_PACK_SELECT_FROM_PACK (node), + indent+4); + indent_to (file, indent + 3); + fprintf (file, "index %d", ARGUMENT_PACK_SELECT_INDEX (node)); + break; default: break; } diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 3b5edeb..58c9613 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -321,7 +321,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent) if (indent <= 4) print_node_brief (file, "type", TREE_TYPE (node), indent + 4); } - else + else if (CODE_CONTAINS_STRUCT (code, TS_TYPED)) { print_node (file, "type", TREE_TYPE (node), indent + 4); if (TREE_TYPE (node))