From patchwork Sat Sep 4 14:32:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 63790 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 0F3D3B7148 for ; Sun, 5 Sep 2010 00:33:08 +1000 (EST) Received: (qmail 4368 invoked by alias); 4 Sep 2010 14:33:03 -0000 Received: (qmail 4337 invoked by uid 22791); 4 Sep 2010 14:33:01 -0000 X-SWARE-Spam-Status: No, hits=2.4 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RCVD_IN_JMF_BL, SPF_NEUTRAL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp23.services.sfr.fr (HELO smtp23.services.sfr.fr) (93.17.128.19) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Sep 2010 14:32:57 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2302.sfr.fr (SMTP Server) with ESMTP id A25487000096; Sat, 4 Sep 2010 16:32:55 +0200 (CEST) Received: from gimli.local (122.183.72-86.rev.gaoland.net [86.72.183.122]) by msfrf2302.sfr.fr (SMTP Server) with ESMTP id 2B5667000088; Sat, 4 Sep 2010 16:32:53 +0200 (CEST) X-SFR-UUID: 20100904143253177.2B5667000088@msfrf2302.sfr.fr Message-ID: <4C82586C.1050705@sfr.fr> Date: Sat, 04 Sep 2010 16:32:12 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; fr-FR; rv:1.9.1.11) Gecko/20100725 Thunderbird/3.0.6 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [Patch, fortran] [9/11] Inline transpose part 1 References: <4C8254A0.9020907@sfr.fr> In-Reply-To: <4C8254A0.9020907@sfr.fr> X-IsSubscribed: yes 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 I hope I got it right for this one. It is a fix for a regression in alloc_comp_transformational_1.f90 We have to set the proper flag for gfc_trans_scalar_assign to do a recursive assignment on derived types. OK for trunk? 2010-09-03 Mikael Morin * trans-expr.c (expr_is_variable): New function taking non-copying intrinsic functions into account. (gfc_trans_assignment_1): Use expr_is_variable. diff --git a/trans-expr.c b/trans-expr.c index 937a832..b6774ef 100644 --- a/trans-expr.c +++ b/trans-expr.c @@ -5468,6 +5468,27 @@ gfc_trans_array_constructor_copy (gfc_expr * expr1, gfc_expr * expr2) } +/* Tells whether the expression is to be treated as a variable reference. */ + +static bool +expr_is_variable (gfc_expr *expr) +{ + gfc_expr *arg; + + if (expr->expr_type == EXPR_VARIABLE) + return true; + + arg = gfc_get_noncopying_intrinsic_argument (expr); + if (arg) + { + gcc_assert (expr->value.function.isym->id == GFC_ISYM_TRANSPOSE); + return expr_is_variable (arg); + } + + return false; +} + + /* Subroutine of gfc_trans_assignment that actually scalarizes the assignment. EXPR1 is the destination/LHS and EXPR2 is the source/RHS. init_flag indicates initialization expressions and dealloc that no @@ -5593,7 +5614,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, must have its components deallocated afterwards. */ scalar_to_array = (expr2->ts.type == BT_DERIVED && expr2->ts.u.derived->attr.alloc_comp - && expr2->expr_type != EXPR_VARIABLE + && !expr_is_variable (expr2) && !gfc_is_constant_expr (expr2) && expr1->rank && !expr2->rank); if (scalar_to_array && dealloc) @@ -5604,8 +5625,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, l_is_temp || init_flag, - (expr2->expr_type == EXPR_VARIABLE) - || scalar_to_array, dealloc); + expr_is_variable (expr2) || scalar_to_array, + dealloc); gfc_add_expr_to_block (&body, tmp); if (lss == gfc_ss_terminator)