From patchwork Mon Aug 10 15:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 1342879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=eHF1/HDp; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BQK3d0MHKz9sRK for ; Tue, 11 Aug 2020 01:03:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74030385703B; Mon, 10 Aug 2020 15:03:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by sourceware.org (Postfix) with ESMTPS id 5E4543857032; Mon, 10 Aug 2020 15:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5E4543857032 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vehre@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1597071809; bh=ewcJPelHZP8jEDPIRkYCM53VWcsnKlkGBgbaiP+QTEU=; h=X-UI-Sender-Class:Date:From:To:Subject; b=eHF1/HDptKXJcBKBEdvTkexE5KJPlWwQqRUhMnNvWoJAaPM7jxElIylhQe8p89wnr q6KRq5eiduQCtr0wPf4+des0FF4nRyFlYkzTU6BlK7p6Ica2npOOebaYZ5crVL0H10 CPReR7bkzLmpZSP2CbFinm386WLBrCbaw5HUJQUk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from vepi2 ([37.201.215.187]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MuDXz-1kz3D21AuT-00uaoZ; Mon, 10 Aug 2020 17:03:29 +0200 Date: Mon, 10 Aug 2020 17:03:27 +0200 From: Andre Vehreschild To: GCC-Fortran-ML , GCC-Patches-ML Subject: [Patch, fortran] PR93671 - gfortran 8-10 ICE on intrinsic assignment to allocatable derived-type component of coarray Message-ID: <20200810170327.6626f1cb@vepi2> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Provags-ID: V03:K1:KdyXyhnJhXy8O2G7ksrln8Jgdo1a2aGrQyAyJ/FagvHryNAQmrp uPtTxAQhVqwrNWDx6JVRt1I04otkUJso6pOC2xNGMuvmL9uNtkzrQ1kwsVwY/FAr3dT6cGw FJbaSAAXtLpCGULYzbvW//gj/1NjdWNnY5BLfD7kkSD6tYtqSMoSwHzuB+aL2U9LWHkTTs5 b0YGvEsHHEHdc8wjS35vw== X-UI-Out-Filterresults: notjunk:1;V03:K0:P7Ru2wya+rE=:yiKsqwP8T2VXz7k6o2y6xQ HpOlOjqX9ZOsOxyx9qmSGCGTUQ958yvHoRxSZ1M7y/6bApZiMatmDmTMXmHkaLBg16kg1TAxG +pDavMQChkTXGtGckMfqp8dfsULusptf1dnHBN9CLy5vZXA+TII8IqLkTBbNiBLlqc7CLCtwS Pz/AFxToqxHiLKBxprG4dJDrBE6AnapNQf5d3L8SoKia5gbjr9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efq X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi folks, long time, no see. I was asked by Damian to do some Coarray stuff in gfortran so here is the first step on fixing a bug. The issue at hand is, that the coarray handling is not propagated correctly and later on the coarray-token not generated/retrieved from the correct position leading to coarray programs to crash/hang. This patch fixes at least the misbehavior reported in the PR. More to come. Regtests ok on FC31.x86_64. Ok for trunk? Regards, Andre --- Andre Vehreschild * Email: vehre ad gmx dot de gcc/fortran/ChangeLog: 2020-08-10 Andre Vehreschild PR fortran/93671 * trans-array.c (structure_alloc_comps): Keep caf-mode when applying to components; get the caf_token correctly for allocated scalar components. gcc/testsuite/ChangeLog: 2020-08-10 Andre Vehreschild PR fortran/93671 * gfortran.dg/coarray/pr93671.f90: New test. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8f93b43bafb..7a1b2fc74c9 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -8627,14 +8627,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, vref = gfc_build_array_ref (var, index, NULL); - if ((purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP) - && !caf_enabled (caf_mode)) + if (purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP) { tmp = build_fold_indirect_ref_loc (input_location, gfc_conv_array_data (dest)); dref = gfc_build_array_ref (tmp, index, NULL); tmp = structure_alloc_comps (der_type, vref, dref, rank, - COPY_ALLOC_COMP, 0, args); + COPY_ALLOC_COMP, caf_mode, args); } else tmp = structure_alloc_comps (der_type, vref, NULL_TREE, rank, purpose, @@ -9375,12 +9374,21 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, else if (flag_coarray == GFC_FCOARRAY_LIB && caf_in_coarray (caf_mode)) { - tree dst_tok = c->as ? gfc_conv_descriptor_token (dcmp) - : fold_build3_loc (input_location, - COMPONENT_REF, - pvoid_type_node, dest, - c->caf_token, - NULL_TREE); + tree dst_tok; + if (c->as) + dst_tok = gfc_conv_descriptor_token (dcmp); + else + { + /* For a scalar allocatable component the caf_token is + the next component. */ + if (!c->caf_token) + c->caf_token = c->next->backend_decl; + dst_tok = fold_build3_loc (input_location, + COMPONENT_REF, + pvoid_type_node, dest, + c->caf_token, + NULL_TREE); + } tmp = duplicate_allocatable_coarray (dcmp, dst_tok, comp, ctype, rank); } diff --git a/gcc/testsuite/gfortran.dg/coarray/pr93671.f90 b/gcc/testsuite/gfortran.dg/coarray/pr93671.f90 new file mode 100644 index 00000000000..8d26ff88753 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/pr93671.f90 @@ -0,0 +1,24 @@ +! { dg-do run } + +! PR/fortran 93671 - ICE on intrinsic assignment to allocatable derived-type +! component of coarray + + type flux_planes + integer, allocatable :: normals + end type + + type package + type(flux_planes) surface_fluxes(1) + end type + + type(package) mail[*], halo_data + + halo_data%surface_fluxes(1)%normals = 1 + mail = halo_data + + if (any(size(mail%surface_fluxes) /= [1]) .OR. & + mail%surface_fluxes(1)%normals /= 1) then + stop 1 + end if +end +