From patchwork Wed Jun 13 07:54:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 164559 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 8F04AB6FCB for ; Wed, 13 Jun 2012 17:55:31 +1000 (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=1340178931; 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=Zlc5OVa qbtonTrVpsQbTcJeDuIQ=; b=kNxj2IQMUIh3qk6zbWZf97EwTdIL/tNhmz0YEjP 4K1+1+jOAyTFMsElrLm73XQNONWTFAvdkx6xU9/3V1AEpieLTIrKLllUA21FfeyQ RYspGd8GD3sK4JDUHph9wDaGNx04bi2WDnGWUhF6CD1IDf6DC6/zUuTfZuexl9mx +O7Q= 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=h6p3VnNPe+zMBddJNRlqMZKyJTMuq0y3/KPvujWTipi5hvjXreFa3ws3yEwd1S UJ/GETk3PpzB2rv8LD5PdZL9aZnUgfUP5jIkzlbif5Zxd6oA+F4xFjxNYG7U58gX SyXez/mA+Y4246iybX/AX8kb3m0TeFO0nIioGzmJeHpac=; Received: (qmail 32159 invoked by alias); 13 Jun 2012 07:55:19 -0000 Received: (qmail 32141 invoked by uid 22791); 13 Jun 2012 07:55:17 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jun 2012 07:55:04 +0000 Received: from [192.168.178.22] (port-92-204-5-252.dynamic.qsc.de [92.204.5.252]) by mx01.qsc.de (Postfix) with ESMTP id A1A743CBB3; Wed, 13 Jun 2012 09:54:56 +0200 (CEST) Message-ID: <4FD8474E.5090808@net-b.de> Date: Wed, 13 Jun 2012 09:54:54 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120601 Thunderbird/13.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR53643 Fix INTENT(OUT) for class arrays 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 gfortran had an ICE with intent(out) class arrays - and with (polymorphic) scalar coarrays. Build and regtested on x86-64-linux. OK for the trunk? Tobias 2012-06-12 Tobias Burnus PR fortran/53643 * trans-decl.c (init_intent_out_dt): Fix for polymorphic arrays. * trans-array.c (structure_alloc_comps): Don't loop for scalar coarrays. 2012-06-12 Tobias Burnus PR fortran/53643 * gfortran.dg/intent_out_7.f90: New. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 2534462..0e78210 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -7318,9 +7318,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if ((POINTER_TYPE_P (decl_type) && rank != 0) || (TREE_CODE (decl_type) == REFERENCE_TYPE && rank == 0)) - - decl = build_fold_indirect_ref_loc (input_location, - decl); + decl = build_fold_indirect_ref_loc (input_location, decl); /* Just in case in gets dereferenced. */ decl_type = TREE_TYPE (decl); @@ -7328,7 +7326,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, /* If this an array of derived types with allocatable components build a loop and recursively call this function. */ if (TREE_CODE (decl_type) == ARRAY_TYPE - || GFC_DESCRIPTOR_TYPE_P (decl_type)) + || (GFC_DESCRIPTOR_TYPE_P (decl_type) && rank != 0)) { tmp = gfc_conv_array_data (decl); var = build_fold_indirect_ref_loc (input_location, diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 637376b..75a2160 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -3451,12 +3451,9 @@ init_intent_out_dt (gfc_symbol * proc_sym, gfc_wrapped_block * block) && !CLASS_DATA (f->sym)->attr.class_pointer && CLASS_DATA (f->sym)->ts.u.derived->attr.alloc_comp) { - tree decl = build_fold_indirect_ref_loc (input_location, - f->sym->backend_decl); - tmp = CLASS_DATA (f->sym)->backend_decl; - tmp = fold_build3_loc (input_location, COMPONENT_REF, - TREE_TYPE (tmp), decl, tmp, NULL_TREE); - tmp = build_fold_indirect_ref_loc (input_location, tmp); + tmp = gfc_class_data_get (f->sym->backend_decl); + if (CLASS_DATA (f->sym)->as == NULL) + tmp = build_fold_indirect_ref_loc (input_location, tmp); tmp = gfc_deallocate_alloc_comp (CLASS_DATA (f->sym)->ts.u.derived, tmp, CLASS_DATA (f->sym)->as ? --- /dev/null 2012-06-12 08:13:11.079779038 +0200 +++ gcc/gcc/testsuite/gfortran.dg/intent_out_7.f90 2012-06-13 09:45:19.000000000 +0200 @@ -0,0 +1,26 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/53643 +! +type t + integer, allocatable :: comp +end type t +contains + subroutine foo(x,y) + class(t), allocatable, intent(out) :: x(:) + class(t), intent(out) :: y(:) + end subroutine + subroutine foo2(x,y) + class(t), allocatable, intent(out) :: x + class(t), intent(out) :: y + end subroutine + subroutine bar(x,y) + class(t), intent(out) :: x(:)[*] + class(t), intent(out) :: y[*] + end subroutine + subroutine bar2(x,y) + type(t), intent(out) :: x(:)[*] + type(t), intent(out) :: y[*] + end subroutine +end