From patchwork Tue Feb 23 10:30:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 586803 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A6A7A1409A0 for ; Tue, 23 Feb 2016 21:30:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=hR43J99q; dkim-atps=neutral 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:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=tMXi2utnqhRgZWY9 kiPssFt4iQnP482djLVR73hDUrwJrakKUxyLuc1FLFpWzkIQV8Y0tS4UYtVT6KFD /zEAZZVoISCMsqplQN1csbqIIutsYxmMAqO+6bWGgEhZHWL9cmFuFVonKzM7AyJD NPUtF9YmBZdYsEeeKjxTgxUyKKQ= 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:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=Del5YfFnqFAsFgDUU5x/vr kRgTA=; b=hR43J99qJ9MbuPfHIzQtDpIhEuiqef33B9Bkz5fKbrOhnufklVE0xM ff4AtZTtevsFI6BEILkdmvGOwTjLdulI0Eatk5sCVGyELSVLrC5vjghCQ4anFqqS GYY3z1Q6P3sp66XZdgOCROLJrGeOMcPoGygZud+cS0CO441Dptzrs= Received: (qmail 47103 invoked by alias); 23 Feb 2016 10:30:33 -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 47065 invoked by uid 89); 23 Feb 2016 10:30:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_20, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=Ian, paul.richard.thomas@gmail.com, paulrichardthomasgmailcom, Contributed X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Feb 2016 10:30:24 +0000 Received: from vepi2 ([92.213.0.123]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MH0eg-1alrbM1KOQ-00Dmeh; Tue, 23 Feb 2016 11:30:18 +0100 Date: Tue, 23 Feb 2016 11:30:16 +0100 From: Andre Vehreschild To: Paul Richard Thomas Cc: GCC-Patches-ML , GCC-Fortran-ML Subject: Re: [Patch, fortran, pr67451, v1] [5/6 Regression] ICE with sourced allocation from coarray Message-ID: <20160223113016.2df6c0ed@vepi2> In-Reply-To: References: <20160129191724.2eb47e1b@vepi2> <20160210122624.2114b57d@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:wsoCHSJKOTI=:GvPp/yiyKbt/iREqN5Q3QH HMVdje9yw7tUwAsGwcR1G4vA74b3NldXdSsMfW4AHoahqpac7HdPHMRXgDZFz2ufTDQqA3n9s RWWFGUOatTI6Y5yaeDq7jL0XMHfKcaQiV1TCkam/WWBK6YMETyUcTlPy349VisiulgJv1OxBX +pAB0Pn3ZmEt54xj3P/jUZ/Eyw9z7YSniRq3rR5J2COq31wJhNROivd8F7zT3ok17Z4f7pd+o WBqOu7pPUiMAe3VBw28BSyU3tluu6ujpl0WI8fk3lNjm7NhqG3mQYPlb0SufgHB5V9gklYanh OhN+OzVBNS64cBTYEufdWdXu9omWg3aWIectnps5UBGIU1rjZtFKWlOe1V01jeMCRUyoPpOOi mASk5szX/UcJZmiQTaHflWF2GHb+8Na9siKo8Lhs+QW3fWaPThphyKlImjCdcXbpN6I4NY2UH kbLqbp0CzIpTCGpFLCs5u6NOld4pLGRuj/ZBr3FDSEvSrADZTvmXC2/ke6jFtSJ4Cqpq29EUS kH0G9+vGkIG1fCJ1B6BkSLujg4Huo1/tPLPbuC4ESzx2mWNAVXI0JyXxy8w9U2vOYKP5Zc1PR pGsiuPJs7Pm3qv7cxDHVY5m/AJqEH9UfVSiqGrPl68Pd2MzvzSAdDQwCKXhFMfC1dta536FGM muq/2YNRkpVja8DIK5nnCFCKzyNncN5LlQXeTc8DVyHhwnurtK+5aixL8DIJHC3m5IZlwZaFm jFOzZX3vxP2XoADiL8z7YvKNIAHWsIfzhbB0PKX9MEFzjZkTbvg9ueL7IBs= Hi Paul, thanks for the review. Committed as r233625. Regards, Andre On Wed, 17 Feb 2016 14:13:48 +0100 Paul Richard Thomas wrote: > Dear Andre, > > I had left this to somebody else, since I am travelling! > > The patch is verging on 'obvious' and so it is OK for trunk. > > Could you check the line terminators please? I am seeing CR-LFs but > this might be an effect of transmission. > > Thanks for the patch. > > Paul > > On 10 February 2016 at 12:26, Andre Vehreschild wrote: > > Hi all, > > > > unfortunately was my last patch for pr67451 not perfect and introduced > > regressions occurring on s390(x) and with the sanitizer. These were > > caused, because when taking the array specs from the source=-expression > > also its attributes, like coarray state and so on where taken from > > there. This additionally added a corank to local objects to allocate, > > that were no coarrays overwriting data in the array handle. The attached > > patch fixes both issues. > > > > The patch for gcc-5 is not affected, because in gcc-5 the feature of > > taking the array spec from the source=-expression is not implemented. > > > > Bootstrapped and regtested ok on x86_64-linux-gnu/F23. > > > > Ok for trunk? > > > > Regards, > > Andre > > > > On Tue, 2 Feb 2016 19:24:46 +0100 > > Paul Richard Thomas wrote: > > > >> Hi Andre, > >> > >> This looks to be OK for trunk. > >> > >> I'll move to the 5-branch patch right away. > >> > >> Thanks > >> > >> Paul > >> > >> On 29 January 2016 at 19:17, Andre Vehreschild wrote: > >> > Hi all, > >> > > >> > attached is a patch to fix a regression in current gfortran when a > >> > coarray is used in the source=-expression of an allocate(). The ICE was > >> > caused by the class information, i.e., _vptr and so on, not at the > >> > expected place. The patch fixes this. > >> > > >> > The patch also fixes pr69418, which I will flag as a duplicate in a > >> > second. > >> > > >> > Bootstrapped and regtested ok on x86_64-linux-gnu/F23. > >> > > >> > Ok for trunk? > >> > > >> > Backport to gcc-5 is pending, albeit more difficult, because the > >> > allocate() implementation on 5 is not as advanced the one in 6. > >> > > >> > Regards, > >> > Andre > >> > -- > >> > Andre Vehreschild * Email: vehre ad gmx dot de > >> > >> > >> > > > > > > -- > > Andre Vehreschild * Email: vehre ad gmx dot de > > > Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 233624) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2016-02-23 Andre Vehreschild + + PR fortran/67451 + * trans-array.c (gfc_array_allocate): Take the attributes from the + expression to allocate and not from the source=-expression. + 2016-02-20 Paul Thomas PR fortran/69423 Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (Revision 233624) +++ gcc/fortran/trans-array.c (Arbeitskopie) @@ -5401,17 +5401,8 @@ if (!retrieve_last_ref (&ref, &prev_ref)) return false; - if (ref->u.ar.type == AR_FULL && expr3 != NULL) - { - /* F08:C633: Array shape from expr3. */ - ref = expr3->ref; - - /* Find the last reference in the chain. */ - if (!retrieve_last_ref (&ref, &prev_ref)) - return false; - alloc_w_e3_arr_spec = true; - } - + /* Take the allocatable and coarray properties solely from the expr-ref's + attributes and not from source=-expression. */ if (!prev_ref) { allocatable = expr->symtree->n.sym->attr.allocatable; @@ -5428,6 +5419,17 @@ if (!dimension) gcc_assert (coarray); + if (ref->u.ar.type == AR_FULL && expr3 != NULL) + { + /* F08:C633: Array shape from expr3. */ + ref = expr3->ref; + + /* Find the last reference in the chain. */ + if (!retrieve_last_ref (&ref, &prev_ref)) + return false; + alloc_w_e3_arr_spec = true; + } + /* Figure out the size of the array. */ switch (ref->u.ar.type) { @@ -5463,7 +5465,8 @@ gfc_init_block (&set_descriptor_block); size = gfc_array_init_size (se->expr, alloc_w_e3_arr_spec ? expr->rank : ref->u.ar.as->rank, - ref->u.ar.as->corank, &offset, lower, upper, + coarray ? ref->u.ar.as->corank : 0, + &offset, lower, upper, &se->pre, &set_descriptor_block, &overflow, expr3_elem_size, nelems, expr3, e3_arr_desc, e3_is_array_constr, expr); Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 233624) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2016-02-23 Andre Vehreschild + + PR fortran/67451 + * gfortran.dg/coarray_allocate_5.f08: New test. + 2016-02-23 Andreas Krebbel * gcc.target/s390/vcond-shift.c: Move to ... Index: gcc/testsuite/gfortran.dg/coarray_allocate_5.f08 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_allocate_5.f08 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray_allocate_5.f08 (Arbeitskopie) @@ -0,0 +1,32 @@ +! { dg-do run } +! { dg-options "-fcoarray=lib -lcaf_single -fdump-tree-original" } +! +! Contributed by Ian Harvey +! Extended by Andre Vehreschild +! to test that coarray references in allocate work now +! PR fortran/67451 + + program main + implicit none + type foo + integer :: bar = 99 + end type + class(foo), dimension(:), allocatable :: foobar[:] + class(foo), dimension(:), allocatable :: some_local_object + allocate(foobar(10)[*]) + + allocate(some_local_object, source=foobar) + + if (.not. allocated(foobar)) call abort() + if (lbound(foobar, 1) /= 1 .OR. ubound(foobar, 1) /= 10) call abort() + if (.not. allocated(some_local_object)) call abort() + if (any(some_local_object(:)%bar /= [99, 99, 99, 99, 99, 99, 99, 99, 99, 99])) call abort() + + deallocate(some_local_object) + deallocate(foobar) + end program + +! Check that some_local_object is treated as rank-1 array. +! This failed beforehand, because the coarray attribute of the source=expression +! was propagated to some_local_object in the allocate. +! { dg-final { scan-tree-dump-not "some_local_object\._data\.dim\[1\]\.lbound" "original" } }