From patchwork Mon Jan 7 16:58:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 210001 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 2B8FC2C009A for ; Tue, 8 Jan 2013 03:58:50 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1358182731; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=GTBVUrGaEFv//BHBun2inM8uOeo=; b=CpZgia2AdZYRQu0 D2kjekRB48T8w+Q015S9c/brNmdwBRLqVpGkddzUfP2BPxa5e7tT5kTTvSQVtQOg ZgBg00A0lSGJ/2DNnzDZbaA7XVpYBWZhfoHyYskhFuA6jYr6xCG6TvGab1iv9jAl S1mT/+pVoQhNt1q4iLVM+AeL+Ocg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=M6d1wcJyV/1Xcmwf8MMktj8IJ4q9oCFbPuAMapJLv3Ema1K1vOaRfVbVDT3kwm Hs3U//fNQ3IT6shwwH7D7+stZqQNmClGqSbfZFDjVcUR0fX6RpTdS6qedx6/y4xa 3dHFltCVAR9bj3RZNMFpa96WFtm8Hc5kOGieKP2l+pPX0=; Received: (qmail 27403 invoked by alias); 7 Jan 2013 16:58:36 -0000 Received: (qmail 27367 invoked by uid 22791); 7 Jan 2013 16:58:35 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Mon, 07 Jan 2013 16:58:31 +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 r07GwVYX012057 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Jan 2013 11:58:31 -0500 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r07GwUwu010971 for ; Mon, 7 Jan 2013 11:58:30 -0500 Message-ID: <50EAFEB6.8080901@redhat.com> Date: Mon, 07 Jan 2013 11:58:30 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List Subject: Re: C++ PATCH for c++/55753 (ICE with constexpr) References: <50E5EBB1.8020507@redhat.com> In-Reply-To: <50E5EBB1.8020507@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 And another bug: we were building an AGGR_INIT_EXPR in non-dependent code, and then failing to handle it properly in fold_non_dependent_expr. Fixed by not creating AGGR_INIT_EXPR in templates. As a result, we end up with a CALL_EXPR to the address of a constructor, and we need to avoid an error when instantiating that by stripping the address and letting the call code put it back. Tested x86_64-pc-linux-gnu, applying to trunk. This is only an ICE with checking enabled, so I'm not going to apply it to 4.7. commit 843d522093cdc00181ea4590bf69d5f10162998a Author: Jason Merrill Date: Mon Jan 7 09:31:13 2013 -0500 PR c++/55753 * tree.c (build_aggr_init_expr): Do nothing in a template. * pt.c (tsubst_copy_and_build) [CALL_EXPR]: Strip an ADDR_EXPR off a FUNCTION_DECL before tsubsting. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 30bafa0..c55dabef 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13743,6 +13743,11 @@ tsubst_copy_and_build (tree t, else qualified_p = false; + if (TREE_CODE (function) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) + /* Avoid error about taking the address of a constructor. */ + function = TREE_OPERAND (function, 0); + function = tsubst_copy_and_build (function, args, complain, in_decl, !qualified_p, diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index fcab1a4..0824214 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -412,6 +412,10 @@ build_aggr_init_expr (tree type, tree init) tree rval; int is_ctor; + /* Don't build AGGR_INIT_EXPR in a template. */ + if (processing_template_decl) + return init; + if (TREE_CODE (init) == CALL_EXPR) fn = CALL_EXPR_FN (init); else if (TREE_CODE (init) == AGGR_INIT_EXPR) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C new file mode 100644 index 0000000..ed01a31 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C @@ -0,0 +1,15 @@ +// PR c++/55753 +// { dg-options -std=c++11 } + +struct A +{ + double r,i; + constexpr A(double r = 0.0, double i = 0.0): r(r), i(i) {} +}; + +template +struct B { + B() { + A((true ? 1.0 : A())); + } +};