From patchwork Tue Dec 13 13:54:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 87887 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp2213446qgi; Tue, 13 Dec 2016 05:55:38 -0800 (PST) X-Received: by 10.98.201.66 with SMTP id k63mr102234762pfg.108.1481637338672; Tue, 13 Dec 2016 05:55:38 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 127si48015330pgg.233.2016.12.13.05.55.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2016 05:55:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444296-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444296-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444296-patch=linaro.org@gcc.gnu.org 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=HhYjv9XingO9cXTq f9m2xwjIbsEyPYa87IglAndC54lo+ISqs2YXSiK+zcK7om1HaHasJwbP5UXNiROR fyirCurNdV/qzQtsQ13XDvS0AsNgmxRpkxDwleaqArEjODOiGtunMfy5svBkNhiq Ihyz4u1hwFn+PF5poes6vWznJP4= 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=T39k09BMilAk8HxVNQOxc7 Kkzb0=; b=p53eDTSYyd37a6ZcrxdXa+GXuHAqnkc1TSI0xpLb0c433eP68v7khj GUEjzZgxn3PVcRKELFDIEVkAv7GDBqqAPGgaQqEDNmLsM8pAsJ4uZkCWeVaULxiH hGbzAbAErwVyYrJFd+I6X8XUMJyBuE3LODPV8puFqeR2wBrgEB6zA= Received: (qmail 45787 invoked by alias); 13 Dec 2016 13:54:52 -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 45753 invoked by uid 89); 13 Dec 2016 13:54:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=vehregccgnuorg, vehre@gcc.gnu.org, 2*, mold X-Spam-User: qpsmtpd, 3 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, 13 Dec 2016 13:54:40 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M08ia-1cUsTZ23v2-00uKNb; Tue, 13 Dec 2016 14:54:37 +0100 Date: Tue, 13 Dec 2016 14:54:36 +0100 From: Andre Vehreschild To: Janus Weil Cc: GCC-Patches-ML , GCC-Fortran-ML Subject: Re: [PATCH, fortran, pr77785, v3] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990 Message-ID: <20161213145436.5d293776@vepi2> In-Reply-To: References: <20161212125614.24ca3ca5@vepi2> <20161212184436.212a7185@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:xMMvVSyZOvU=:6gskBLIw9gUdsqVz9SuMic ChT7tdnYSqrssVbs0z/8OnToEQDAwe6j70ty61yH2qP48Et7mOHx91ocYE1KPeOc75rSxuLTV m4WFKAolBLXYFt/sAxWUcc96DHDsg/thtSZIASQ+HFxoLpUGcnb56zW6ExjV+CA9iulP4EZxs 5lWBm+Co3gr1bQ6gWW879NrZ/R2xe6XQPUbaLEnweg56JfuQNrN0TXCES5/wq6UBsCDsshQiA SS9VT430A4DmRC5bU4+cApwP6zsnZhwchJr8Tr4kpvADNLcExcrpJ6vvftG/S12bZV2MU3aC0 Pm7DiweBHNY3DU7Tefba9hzaNr/BsmEzXHd674I6yQqcJYvq+Rl6y/twlzRFlNNRNgaZsCOMG GcJESY0BDX809vjy6NY/DWP1HOoD3nqayr+QAASUzAR2NUunDIbHN6AF9IcxKtCzDGy0j9gn1 3rHIbcwordGM0w5ODdfy/lxbNYRMjs2C9/+G/JNrRqrDyyuohXZ4fZCxqxqDPH1Vjhr/L5BQh lrDxRDIH0abWw6aHnZpyHnQYlzz2SKtddfn5o4re8F5bDUHi2buK8NPMGxMLm1Pe0rpsjxcF5 J1HVTH3Vd9HpcH9bZhoHs/GeBa7mUtI2k8q5rwkSDsjL3Ter0he2uqb47pOfHk2zsPfYD+Zsi iZi504ejviwme/tdIDD5yXuww0a+AUYCyAiKNiv8ntjZc4rmieXizaG+1rXkxr0yfEGgnPVvH hZnUXt6lQZLiK2W1mD0/8Y5/18uj2HVpvt6OZyxnO3P624iXfYuNUweJAbk= Hi Janus, hi all, thanks for the input on the missing testcase, Janus (btw, when you know where to get a new crystal ball, let me know; I am missing mine, too). The new version of the patch adds a new testcase coarray_41.f90 to test that the compiler compiles correctly and the test runs ok. Bootstrapped and regtested on x86_64-linux/f23. Ok for trunk? Regards, Andre On Tue, 13 Dec 2016 12:11:50 +0100 Janus Weil wrote: > Hi Andre, > > > all the sanitizer issues I fixed occur during compiling the testsuite. So I > > would say, that when with the patch these errors do not occur anymore while > > processing the testsuite, then those are tested for, right? > > aah, so you're saying that hunk is not actually related to the PR in > the subject line, but instead fixes a testsuite failure seen with a > sanitized compiler? That wasn't mentioned anywhere and sadly I forgot > to bring my crystal ball ... > > Cheers, > Janus > > > > > On Mon, 12 Dec 2016 13:37:43 +0100 > > Janus Weil wrote: > > > >> Hi Andre, > >> > >> > the attached patch corrects reporting of "Sorry, unimplemented yet" for > >> > allocatable and pointer components in polymorphic objects (BT_CLASS) thus > >> > fixing two ICEs reported in the PR. > >> > > >> > The next chunk fixes an ICE when the declaration containing the token > >> > information is of type POINTER or REFERENCE. > >> > > >> > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk? > >> > >> the resolve.c hunk is certainly ok. The trans-array.c part looks > >> reasonable as well, but I wonder if it is actually covered by any of > >> your test cases? Since they are all compile-only, with errors being > >> thrown at resolution stage, do they even get to the translation stage? > >> > >> Cheers, > >> Janus > > > > > > -- > > Andre Vehreschild * Email: vehre ad gmx dot de -- Andre Vehreschild * Email: vehre ad gmx dot de gcc/fortran/ChangeLog: 2016-12-13 Andre Vehreschild PR fortran/77785 * resolve.c (resolve_symbol): Correct attr lookup to the _data component. * trans-array.c (gfc_alloc_allocatable_for_assignment): Indirect ref pointers and references before retrieving the caf-token. gcc/testsuite/ChangeLog: 2016-12-13 Andre Vehreschild PR fortran/77785 * gfortran.dg/coarray_38.f90: Added expecting error message. * gfortran.dg/coarray_41.f90: New test. * gfortran.dg/coarray_class_2.f90: New test. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index c7d872c..b610797 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -14044,8 +14044,8 @@ resolve_symbol (gfc_symbol *sym) if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS && sym->ts.u.derived && CLASS_DATA (sym) && CLASS_DATA (sym)->attr.codimension - && (sym->ts.u.derived->attr.alloc_comp - || sym->ts.u.derived->attr.pointer_comp)) + && (CLASS_DATA (sym)->ts.u.derived->attr.alloc_comp + || CLASS_DATA (sym)->ts.u.derived->attr.pointer_comp)) { gfc_error ("Sorry, allocatable/pointer components in polymorphic (CLASS) " "type coarrays at %L are unsupported", &sym->declared_at); diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8753cbf..0cd83f4 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -9337,6 +9337,8 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, if (token == NULL_TREE) { tmp = gfc_get_tree_for_caf_expr (expr1); + if (POINTER_TYPE_P (TREE_TYPE (tmp))) + tmp = build_fold_indirect_ref (tmp); gfc_get_caf_token_offset (&caf_se, &token, NULL, tmp, NULL_TREE, expr1); token = gfc_build_addr_expr (NULL_TREE, token); diff --git a/gcc/testsuite/gfortran.dg/coarray_38.f90 b/gcc/testsuite/gfortran.dg/coarray_38.f90 index c8011d4..04ef742 100644 --- a/gcc/testsuite/gfortran.dg/coarray_38.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_38.f90 @@ -92,7 +92,7 @@ end type t type t2 class(t), allocatable :: caf2[:] end type t2 -class(t), save, allocatable :: caf[:] +class(t), save, allocatable :: caf[:] ! { dg-error "Sorry, allocatable/pointer components in polymorphic" } type(t) :: x type(t2) :: y diff --git a/gcc/testsuite/gfortran.dg/coarray_41.f90 b/gcc/testsuite/gfortran.dg/coarray_41.f90 new file mode 100644 index 0000000..b62d8e4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_41.f90 @@ -0,0 +1,29 @@ +! { dg-do run } +! { dg-options "-fcoarray=lib -lcaf_single" } + +program coarray_41 + + integer, allocatable :: vec(:)[:,:] + + allocate(vec(10)[2,*], source= 37) + + if (.not. allocated(vec)) error stop + + call foo(vec) + + if (any(vec /= 42)) error stop + + deallocate(vec) +contains + + subroutine foo(gv) + + integer, allocatable, intent(inout) :: gv(:)[:,:] + integer, allocatable :: gvin(:) + + allocate(gvin, mold=gv) + gvin = 5 + gv = gv + gvin + end subroutine foo + +end program coarray_41 diff --git a/gcc/testsuite/gfortran.dg/coarray_class_2.f90 b/gcc/testsuite/gfortran.dg/coarray_class_2.f90 new file mode 100644 index 0000000..58dce1a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_class_2.f90 @@ -0,0 +1,45 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! Check that error message is presented as long as polymorphic coarrays are +! not implemented. + +module maccscal + type t + real, allocatable :: a + end type +contains + subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" } + class(t) :: x[*] + allocate (x%a) + end +end +module mptrscal + type t + real, pointer :: a + end type +contains + subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" } + class(t) :: x[*] + allocate (x%a) + end +end +module mallarr + type t + real, allocatable :: a(:) + end type +contains + subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" } + class(t) :: x[*] + allocate (x%a(2)) + end +end +module mptrarr + type t + real, pointer :: a(:) + end type +contains + subroutine s(x) ! { dg-error "Sorry, allocatable/pointer components in polymorphic \\(CLASS\\)" } + class(t) :: x[*] + allocate (x%a(2)) + end +end