From patchwork Thu Mar 3 16:52:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 85298 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 AB39AB70A9 for ; Fri, 4 Mar 2011 03:52:40 +1100 (EST) Received: (qmail 30481 invoked by alias); 3 Mar 2011 16:52:37 -0000 Received: (qmail 30473 invoked by uid 22791); 3 Mar 2011 16:52:36 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Thu, 03 Mar 2011 16:52:27 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p23GqPHB022348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 Mar 2011 11:52:25 -0500 Received: from [127.0.0.1] (ovpn-113-31.phx2.redhat.com [10.3.113.31]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p23GqPnY027766 for ; Thu, 3 Mar 2011 11:52:25 -0500 Message-ID: <4D6FC748.1090909@redhat.com> Date: Thu, 03 Mar 2011 11:52:24 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: Re: C++ PATCH for c++/47950 (ICE with condition in template) References: <4D6F223D.2070608@redhat.com> In-Reply-To: <4D6F223D.2070608@redhat.com> 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 On 03/03/2011 12:08 AM, Jason Merrill wrote: > The problem here was that we were folding the initializer too many > times, so we lost the TREE_CONSTANT on the TARGET_EXPR. Since we already > fold in cp_parser_initializer_clause, it's redundant to do so in > cp_parser_condition as well. It occurred to me that a more robust fix would be to make it so redundant folding doesn't cause an ICE here. Tested x86_64-pc-linux-gnu, applied to trunk. commit a0390d566c766d20b49735be27913666a1e7ffad Author: Jason Merrill Date: Thu Mar 3 00:08:21 2011 -0500 PR c++/47950 * pt.c (tsubst_copy_and_build) [TARGET_EXPR]: Retain TREE_CONSTANT. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4b262d0..60b2699 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13368,7 +13368,11 @@ tsubst_copy_and_build (tree t, /* We can get here for a constant initializer of non-dependent type. FIXME stop folding in cp_parser_initializer_clause. */ gcc_assert (TREE_CONSTANT (t)); - return get_target_expr (RECUR (TARGET_EXPR_INITIAL (t))); + { + tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t))); + TREE_CONSTANT (r) = true; + return r; + } default: /* Handle Objective-C++ constructs, if appropriate. */