From patchwork Thu Jun 25 14:06:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1316945 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=codesourcery.com 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 49t1z663KLz9s1x for ; Fri, 26 Jun 2020 00:06:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D53D3851C34; Thu, 25 Jun 2020 14:06:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 3E47A3858D34; Thu, 25 Jun 2020 14:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E47A3858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: mmHEdMKZbXB5JCWUq2bVMewoW49zShjmoGXGjqRSoBuRBRrx+pQG8r+135JKBIgawt65vRi9Fo XFtOiA6XQN6pdGWLrlY4/02HPiLGXP1ZsjhHhHkqfYEgbeOWhZHogwjVrjf3QvZ7ncoj/ic0n6 nkpPhvObzUV3TO/RVdB0fFfaDqflpZ7SpnTqyVSTVRfG1kH1RInh34bMs/OYVY92JHM8w4bYKG lAMn7p77mbMwR+Hc42yFPl2L6npAuR3L51Sh2cbDeCy6nsIGlHwbFGOX5Ihav6oEX6Rv/haDba WWs= X-IronPort-AV: E=Sophos;i="5.75,279,1589270400"; d="diff'?scan'208";a="50312303" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 25 Jun 2020 06:06:31 -0800 IronPort-SDR: eFdnKSBmQSRZqj5EyD+x5pjvmtENgQfcPEKP+Jy2vq1QCFqRYfOVeA1hy17o1r3kf/4As50Evs xTD/XkIlecMmjoDlzdZxriu1b43GJADLxF9adrnjrv+ajoXN6HOvWsML3U10J5UM8VnjwGf9Tg jeOaRdyKr/+DMSta4AZc5VXTqU5R07tZrc5RYZrA5SCy8EUT/wf0/uuWI3nGpuJgHv47odsms9 kj6UCv7vlbcJ7FFe2fq0+3qZz3kWIJyEawrpRUJcBpYm246o+2dp8Wkcxbk4vRQxCy2tk8CdO9 YMQ= To: gcc-patches , fortran , Jakub Jelinek From: Tobias Burnus Subject: [Patch][Fortran, OpenMP] Fix allocatable-components check (PR67311) Message-ID: Date: Thu, 25 Jun 2020 16:06:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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" The test case was giving an ICE as it recursively called itself. Rather obvious fix. OK for the trunk? Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter [Fortran, OpenMP] Fix allocatable-components check (PR67311) gcc/fortran/ChangeLog: PR fortran/67311 * trans-openmp.c (gfc_has_alloc_comps): Return false also for pointers to arrays. libgomp/ChangeLog: PR fortran/67311 * testsuite/libgomp.fortran/target-map-1.f90: New test. gcc/fortran/trans-openmp.c | 5 +++ libgomp/testsuite/libgomp.fortran/target-map-1.f90 | 41 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 22f8f96a60e..01d82ac11d1 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -330,6 +330,11 @@ gfc_has_alloc_comps (tree type, tree decl) return false; } + if (GFC_DESCRIPTOR_TYPE_P (type) + && (GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER + || GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_POINTER_CONT)) + return false; + if (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type)) type = gfc_get_element_type (type); diff --git a/libgomp/testsuite/libgomp.fortran/target-map-1.f90 b/libgomp/testsuite/libgomp.fortran/target-map-1.f90 new file mode 100644 index 00000000000..6107530d292 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-map-1.f90 @@ -0,0 +1,41 @@ +! PR fortran/67311 + +implicit none + TYPE myType + integer :: A + TYPE(myType), DIMENSION(:), POINTER :: x + TYPE(myType), DIMENSION(:), contiguous, POINTER :: y + integer :: B + END TYPE myType + call openmp_sub +contains + subroutine openmp_sub + type(myType) :: argument + + !$OMP PARALLEL DEFAULT(NONE) PRIVATE(argument) + argument%a = 5 + argument%b = 7 + call foo(argument) + if (.not.associated(argument%x) .or. size(argument%x) /= 2) stop 2 + if (argument%a /= 8 .or. argument%b /= 9 & + .or. any(argument%x(:)%a /= [2, 3]) & + .or. any(argument%x(:)%b /= [9, 1])) stop 3 + if (.not.associated(argument%y) .or. size(argument%y) /= 3) stop 4 + if (any(argument%y(:)%a /= [11, 22, 33]) & + .or. any(argument%y(:)%b /= [44, 55, 66])) stop 5 + deallocate (argument%x, argument%y) + !$OMP END PARALLEL + end subroutine openmp_sub + subroutine foo(x) + type(myType), intent(inout) :: x + !$omp declare target + if (x%a /= 5 .or. x%b /= 7) stop 1 + x%a = 8; x%b = 9 + allocate (x%x(2)) + x%x(:)%a = [2, 3] + x%x(:)%b = [9, 1] + allocate (x%y(3)) + x%y(:)%a = [11, 22, 33] + x%y(:)%b = [44, 55, 66] + end subroutine +end