From patchwork Sat Dec 8 00:38:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 204641 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 0BF122C01FB for ; Sat, 8 Dec 2012 17:16:29 +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=1355552190; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=4WNxMH7 P/Qt2gkcSBy59nSeZZzk=; b=hRFznF6R9w8nAE6nweqTsqoVclbjSSUQRVV1HjT UrUeGFj8l1wIKSuqJxexXTdrfKiNXs5Zhv4hdzZb5kKrsK7wmw9F9ov6Pc1fl6xY M0k1SjayR6RBm7MNbCx295i1C88WK+ftT9++qQpMIbOoltyUYE/nRrWyh7vOKbI+ mSMg= 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:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dhnKbI+HGSC0xYeXwZfuIMSLMsSfR5n+JdtmqYs4PBTp7eerHI3J9XSl4VCSsx L3C59BdWOTRlTGtaWN+a71u13B0H2XGFuxgYbzHywvAe8/BI3bPF8XrSxK9VwOsm R7GK7f8yOmN1jmQlf3PtILdEqv5Ki82Bd0J7VAFlRPPk0=; Received: (qmail 27738 invoked by alias); 8 Dec 2012 06:16:23 -0000 Received: (qmail 27726 invoked by uid 22791); 8 Dec 2012 06:16:22 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, 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; Sat, 08 Dec 2012 06:16:14 +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 qB80cJoF004431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Dec 2012 19:38:19 -0500 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB80cI5C029646 for ; Fri, 7 Dec 2012 19:38:18 -0500 Message-ID: <50C28BFA.5060705@redhat.com> Date: Fri, 07 Dec 2012 19:38:18 -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: C++ PATCH for c++/55419 (TREE_CONSTANT on TARGET_EXPR) 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 The analysis of 55419 pointed out the conflict in a TARGET_EXPR having both TREE_SIDE_EFFECTS and TREE_CONSTANT set. After reading that I decided to stop setting TREE_CONSTANT on the TARGET_EXPR and do the necessary work to adjust for that. And then was surprised to find that no additional work was necessary. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit b0f1533a6e7981e5ae12809a60f7b4a96221ff13 Author: Jason Merrill Date: Fri Dec 7 10:42:01 2012 -0500 PR c++/55419 * tree.c (build_target_expr): Don't set TREE_CONSTANT. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ca82f75..963bb1b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -329,8 +329,6 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain) side-effects, then the optimizer should be able to get rid of whatever code is generated anyhow. */ TREE_SIDE_EFFECTS (t) = 1; - if (literal_type_p (type)) - TREE_CONSTANT (t) = TREE_CONSTANT (value); return t; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C new file mode 100644 index 0000000..6b822a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C @@ -0,0 +1,27 @@ +// PR c++/55419 +// { dg-options -std=c++11 } + +struct P +{ + P () = default; + explicit constexpr P (int x) : p (x) {} + int p; +}; + +struct Q +{ + constexpr Q () : q (0x7f) {} + int q; +}; + +struct R +{ + Q q; + P p; +}; + +void +foo (R *x) +{ + *x = {}; +}