From patchwork Tue Jan 31 22:22:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 138870 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 8E686B6EF3 for ; Wed, 1 Feb 2012 09:23:04 +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=1328653385; h=Comment: DomainKey-Signature: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=/BU+0HF T8gVsUEWC5GrkFGsKkdM=; b=KxBXagzdZwpGxhJexAmK9qSqdqoI/hD0+QjwK30 PQ/BFklbfqweSZN+Pnwo+8tXfALG/CEATqw5A9sLnR4yxjP5QK0rs6VVpjpMsxZs xWsDSSayw2r1ZOsLpuKF2EeyFaHP9sHQqTysMaShQdLQQSD/S1VcNgE9MGRJGkn5 zG40= 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: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=eo8uA7weIqro5bvFdGmkUgvcG3/aG1Y42yQgbDO4v9suVUldxakASNiyXmIZts Gi/90SjimOa3P5dYOtr0663HEQvUOUCAjyVOYDfTtv7MgLHUM/GVE+ymAhhswJJu 7ZcXkxLJtLcM03rsL36n7eJo1qFihqdhqKrO6kjCgP2tg=; Received: (qmail 1943 invoked by alias); 31 Jan 2012 22:22:50 -0000 Received: (qmail 1915 invoked by uid 22791); 31 Jan 2012 22:22:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jan 2012 22:22:34 +0000 Received: from [192.168.178.22] (port-92-204-113-100.dynamic.qsc.de [92.204.113.100]) by mx02.qsc.de (Postfix) with ESMTP id A44641E572; Tue, 31 Jan 2012 23:22:33 +0100 (CET) Message-ID: <4F2869A9.8000107@net-b.de> Date: Tue, 31 Jan 2012 23:22:33 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: gcc patches , gfortran , Mikael Morin Subject: [Patch, Fortran] PR52059 - Scalarizing fix - only add array ref to a variable 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 Dear all, I have no idea about the scalarizer, but the attached patch fixes the test case and somehow adding an array ref to a scalar looks odd to me ... (Before the regression-causing patch, only the "else" branch existed.) Build and regtested on x86-64-linux. OK for the trunk? Tobias 2012-01-31 Tobias Burnus PR fortran/52059 * trans-expr.c (gfc_conv_procedure_call): Add array ref only to variables. 2012-01-31 Tobias Burnus PR fortran/52059 * gfortran.dg/elemental_function_1.f90: New. Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 183775) +++ gcc/fortran/trans-expr.c @@ -3519,21 +3519,21 @@ gfc_conv_procedure_call (gfc_se * se, gf CLASS object. */ gfc_init_se (&parmse, se); gfc_conv_derived_to_class (&parmse, e, fsym->ts); } else if (se->ss && se->ss->info->useflags) { /* An elemental function inside a scalarized loop. */ gfc_init_se (&parmse, se); parm_kind = ELEMENTAL; - if (se->ss->dimen > 0 + if (se->ss->dimen > 0 && e->expr_type == EXPR_VARIABLE && se->ss->info->data.array.ref == NULL) { gfc_conv_tmp_array_ref (&parmse); if (e->ts.type == BT_CHARACTER) gfc_conv_string_parameter (&parmse); else parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr); } else gfc_conv_expr_reference (&parmse, e); Index: gcc/testsuite/gfortran.dg/elemental_function_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/elemental_function_1.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/elemental_function_1.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR fortran/52059 +! +! + +subroutine baz + real(kind=8) :: a(99), b + interface bar + function bar (x, y) + integer, intent(in) :: x, y + real(kind=8), dimension((y-x)) :: bar + end function bar + end interface + b = 1.0_8 + a = foo (bar(0,35) / dble(34), b) +contains + elemental real(kind=8) function foo(x, y) + real(kind=8), intent(in) :: x, y + foo = 1 + end function foo +end subroutine baz