From patchwork Tue Apr 2 11:55:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 232982 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1711D2C013A for ; Tue, 2 Apr 2013 22:56:21 +1100 (EST) 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=p32qK7ZULj8AOQRLkQtLYhXiFGlUdtKJ+XjnNNr1RweYRK2/fac1/ el6c2fAZhj78c9CTMcwo5bNO9toZS7hC8C7jaTNqu9C8/Iyu+CF8HGIGyW2Vp6bm nM56FdTQNmjbmAgLsUF4Lw+LytkdsFu4OyfEbm0xNrQU6ZeGTr9GyQ= 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=nSo3pdwbO4s51zdIqGpVlqFyLCo=; b=Ll5ELkPAvcseQ4nIu1ty 5kqztosSU3u0fZCNdqPp+mHLh1PSJh3liqnwacJI2s9Qfi0IG04nUB96UM4lv9gA toSNGN+dahBljUr4eHeCWZEI8vt/D5fnJFCm6zdYTFemVc9LSMU4vqCm8KgTdnDa T3KyJmtx2Bi+l8syiHSvhu0= Received: (qmail 25465 invoked by alias); 2 Apr 2013 11:56:12 -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 25421 invoked by uid 89); 2 Apr 2013 11:56:03 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 02 Apr 2013 11:56:01 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E5CD2A4FFA for ; Tue, 2 Apr 2013 13:55:58 +0200 (CEST) Date: Tue, 2 Apr 2013 13:55:58 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR56768 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 This backports a fix to fix PR56768. Bootstrapped on the 4.7 branch, testing in progress. Richard. 2013-04-02 Richard Biener PR middle-end/56768 Backport from mainline 2012-05-16 Richard Guenther * tree-inline.c (declare_return_variable): Properly handle DECL_BY_REFERENCE return vars in SSA form. * g++.dg/torture/pr56768.C: New testcase. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 196818) +++ gcc/tree-inline.c (working copy) @@ -2983,10 +2983,15 @@ declare_return_variable (copy_body_data if (gimple_in_ssa_p (id->src_cfun)) add_referenced_var (temp); insert_decl_map (id, result, temp); - /* When RESULT_DECL is in SSA form, we need to use it's default_def - SSA_NAME. */ - if (gimple_in_ssa_p (id->src_cfun) && gimple_default_def (id->src_cfun, result)) - temp = remap_ssa_name (gimple_default_def (id->src_cfun, result), id); + /* When RESULT_DECL is in SSA form, we need to remap and initialize + it's default_def SSA_NAME. */ + if (gimple_in_ssa_p (id->src_cfun) + && is_gimple_reg (result)) + { + temp = make_ssa_name (temp, NULL); + insert_decl_map (id, gimple_default_def (id->src_cfun, result), + temp); + } insert_init_stmt (id, entry_bb, gimple_build_assign (temp, var)); } else Index: gcc/testsuite/g++.dg/torture/pr56768.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr56768.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr56768.C (working copy) @@ -0,0 +1,40 @@ +// { dg-do compile } + +struct Iter +{ + int& operator* (); + void operator++ (); +}; + +bool operator!= (Iter &, Iter &) { } + +struct Container +{ + Iter begin () const; + Iter end () const; +}; + +struct J +{ + virtual J *mutable_child (); +}; + +struct M +{ + M (const Container &); + J ns_; +}; +namespace +{ + J MakeNamespace (const Container &src) + { + J a; + J *b = 0; + for (const int &c: src) + b = b ? b->mutable_child () : &a; + return a; + } +} +M::M (const Container &ns):ns_ (MakeNamespace (ns)) +{ +}