From patchwork Mon Jul 22 17:17:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 260768 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 7EA752C009A for ; Tue, 23 Jul 2013 03:19:04 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=vxyQ1leFTURX8n+Q6Psjzsoez5otPnWcECTOeim3kb7+x1 ZqlWbfCGW6dcWplKpxi6cBlC+gg+cs4pXfRahCC7H5O/nGVnGe90uvaqa2g0hiRI D+nhDIekMZiDBBT2YRFC2fI8XZC4Ndval/m5ooB1FkGTB2Adql/OGIQv+2o1Q= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=hPNr+cU25eNqRKKknJC+8P7k4g4=; b=o20JkrVIht9mTSmCcR0B kVHRysAW1fAzfATFaZi2I3GMMFSkgPZ3GhPzeOE81yPqHbtVqwR1UcRwLe6A+OLc 0uqb8ZcHap/gwvNEghcWTly8v0XYsjPNUoGqIASbrHyZoRt/NP/GZA6llj4F+LmX wZ8HM16Bb8oktYUHqKPlLVU= Received: (qmail 21484 invoked by alias); 22 Jul 2013 17:18:28 -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 21420 invoked by uid 89); 22 Jul 2013 17:18:28 -0000 X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RDNS_NONE autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from Unknown (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Jul 2013 17:17:59 +0000 Received: from archimedes.net-b.de (port-92-206-25-210.dynamic.qsc.de [92.206.25.210]) by mx02.qsc.de (Postfix) with ESMTP id 0EB7A2524E; Mon, 22 Jul 2013 19:17:50 +0200 (CEST) Message-ID: <51ED693E.6000305@net-b.de> Date: Mon, 22 Jul 2013 19:17:50 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR57906 - fix issue with coarray component assignment X-Virus-Found: No For coarrays, an assignment does not affect the allocation status. That also implies that the type parameters, shape and effective types between the LHS and RHS have to match. For coarrays components, that's handled (since Rev. 200955) by re-assigning the saved data after the assignment: tmp = LHS; LHS = RHS; LHS.caf = RHS.caf; However, as the PR shows, the middle end for some reasons optimizes the latter assignment away. My impression is that that's due to the "restrict" issue (PR45586). The patch now only assigns the data component, which seems to work: tmp = LHS; LHS = RHS; LHS.caf.data = RHS.caf.data; Other changes: - Change space+tab to tab - Add a test case, which I seemingly forgot to include in r200955 Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2013-07-22 Tobias Burnus PR fortran/57906 PR fortran/52052 * class.c (gfc_build_class_symbol): Set coarray_comp. * trans-array.c (structure_alloc_comps): For coarrays, directly use the data pointer address. 2013-07-22 Tobias Burnus PR fortran/57906 PR fortran/52052 * coarray/lib_realloc_1.f90: Permit optimization. * gfortran.dg/coarray_31.f90: New. diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index ba8efa9..51bfd56 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -666,6 +666,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, fclass->attr.extension = ts->u.derived->attr.extension + 1; fclass->attr.alloc_comp = ts->u.derived->attr.alloc_comp; + fclass->attr.coarray_comp = ts->u.derived->attr.coarray_comp; } fclass->attr.is_class = 1; diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 3fdd8d9..0aac678 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -7589,9 +7589,9 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if ((c->ts.type == BT_DERIVED && !c->attr.pointer) || (c->ts.type == BT_CLASS && !CLASS_DATA (c)->attr.class_pointer)) - { - comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, - decl, cdecl, NULL_TREE); + { + comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, + decl, cdecl, NULL_TREE); /* The finalizer frees allocatable components. */ called_dealloc_with_status @@ -7737,8 +7737,17 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, cdecl, NULL_TREE); dcmp = fold_build3_loc (input_location, COMPONENT_REF, ctype, dest, cdecl, NULL_TREE); + if (c->attr.codimension) - gfc_add_modify (&fnblock, dcmp, comp); + { + if (c->ts.type == BT_CLASS) + { + comp = gfc_class_data_get (comp); + dcmp = gfc_class_data_get (dcmp); + } + gfc_conv_descriptor_data_set (&fnblock, dcmp, + gfc_conv_descriptor_data_get (comp)); + } else { tmp = structure_alloc_comps (c->ts.u.derived, comp, dcmp, diff --git a/gcc/testsuite/gfortran.dg/coarray/lib_realloc_1.f90 b/gcc/testsuite/gfortran.dg/coarray/lib_realloc_1.f90 index ed906f5..f3d7f35 100644 --- a/gcc/testsuite/gfortran.dg/coarray/lib_realloc_1.f90 +++ b/gcc/testsuite/gfortran.dg/coarray/lib_realloc_1.f90 @@ -1,5 +1,4 @@ ! { dg-do run } -! { dg-options "-O0" } ! ! Test that for CAF components _gfortran_caf_deregister is called ! Test that norealloc happens for CAF components during assignment --- /dev/null 2013-07-22 10:09:57.614189406 +0200 +++ gcc/gcc/testsuite/gfortran.dg/coarray_31.f90 2013-07-22 19:13:40.460945010 +0200 @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original -fcoarray=single" } +! +! PR fortran/57906 +! PR fortran/52052 +! +type t + integer, allocatable :: x(:)[:] + class(*), allocatable :: z(:)[:] + class(*), allocatable :: d[:] +end type t +type t2 + type(t) :: y +end type t2 +type(t2) :: a, b +a = b +end + +! { dg-final { scan-tree-dump "a.y.x.data = D.\[0-9\]+.y.x.data;" "original" } } +! { dg-final { scan-tree-dump "a.y.z._data.data = D.\[0-9\]+.y.z._data.data;" "original" } } +! { dg-final { scan-tree-dump "a.y.d._data.data = D.\[0-9\]+.y.d._data.data;" "original" } } +! { dg-final { cleanup-tree-dump "original" } }