From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5865 invoked by alias); 12 Dec 2016 11:56:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5838 invoked by uid 89); 12 Dec 2016 11:56:28 -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=REFERENCE, vehregccgnuorg, vehre@gcc.gnu.org, UD:u.derived X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Dec 2016 11:56:18 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MPUFR-1cL42h3eld-004gCE; Mon, 12 Dec 2016 12:56:15 +0100 Date: Mon, 12 Dec 2016 11:56:00 -0000 From: Andre Vehreschild To: GCC-Patches-ML , GCC-Fortran-ML Subject: [PATCH, fortran, pr77785, v2] [Coarray] ICE in gfc_get_caf_token_offset, at fortran/trans-expr.c:1990 Message-ID: <20161212125614.24ca3ca5@vepi2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/H=OZpQoKo+tvf/FeSd77i34" X-UI-Out-Filterresults: notjunk:1;V01:K0:MdwiI46OH4U=:ON6hr3Z0fyjnmutBLVktOh vekj6qi1tFGjHxtx7rnhikXLhS2qIQeEoiP5FKGJvCb2vf3FCPjejC3tcV3JEguoW46qn062M D4ng+K1ojyAsrpAMkUVsdpN/TA19OZppFdie/phgz2ZzwR+ThIMB8LwHt6lUH8MGVt6F9W6gu 8q/6zhu1I6DiulmeexAgPG3R1C4oDqzSLwVXj6JTnBjZgcfvRgrUribl3ccf0F1V+zh6QJRfy R6nJEeMzjfOMZRBco/K6/+QlBRqMIyWafm4CNpQVPqh1UbD8J+cV8kteRONuDOA7Rn7nO202+ r70MJRn1cl+1cm9869eKUNg+66sZ02219KWotVnnyaSrs1MZ5kvn+1uO+agxi8Ev63TApgLQg LWhgTJQeouKEoy8UQyqF9Cf+HGYO6ha1HDyoHbFXjfHbbnqgBczvZn3MEjEilUHbtZ/7dC6M3 NO2dbZxHUMwhmHE7klFwJkZw83RMcLyzPWlxGcyBfAlH5zmSVUYEC5IHtvHyyfOiOL42i89uj PnSUhCARYYMjAKD6/+7/C3N9xVRxWZpt68QXh0iGjBi/PFFeeqceIn6W1tR7EA1rbExgGr7gz hzcSjxgoZPCjtnzQ0jW5m8ceVHgDIbxKkiTaGw8ftZprgWPyC4sB0SdetrekPmN0XSxIZgjf+ nrYMxWHE66pdDavHVqAQrewbayB+Thz0c0qwMPRkuP+2FOqkQ8J7Y5JYuwsk1KSyItQfZagVz YgGJLgOEJyKSunWrK/RanlX4Tqp+hLw2UftHkFD+yzuy7CYmXI4jVjUA+q8= X-SW-Source: 2016-12/txt/msg01008.txt.bz2 --MP_/H=OZpQoKo+tvf/FeSd77i34 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 431 Hi all, 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? - Andre -- Andre Vehreschild * Email: vehre ad gmx dot de --MP_/H=OZpQoKo+tvf/FeSd77i34 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=pr77785_v2.clog Content-length: 505 gcc/fortran/ChangeLog: 2016-12-12 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-12 Andre Vehreschild PR fortran/77785 * gfortran.dg/coarray_38.f90: Added expecting error message. * gfortran.dg/coarray_class_2.f90: New test. --MP_/H=OZpQoKo+tvf/FeSd77i34 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=pr77785_v2.patch Content-length: 3115 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2093de91..a967bfd 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -14067,8 +14067,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_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 --MP_/H=OZpQoKo+tvf/FeSd77i34--