* [patch, fortran] Fix PR 72714, ICE on invalid
@ 2019-03-03 9:45 Thomas Koenig
2019-03-03 13:07 ` Paul Richard Thomas
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Koenig @ 2019-03-03 9:45 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
Hello world,
the attached patch fixes a 7/8/9 regression by rejecting an invalid
expression in coarray allocation that led to an ICE. It also adds a few
more checks.
One point that is checked for is that, unlike normal arrays, coarrays
cannot be empty.
Regression-tested. OK for trunk and affected branches?
Regards
Thomas
2019-03-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/72714
* resolve.c (resolve_allocate_expr): Add some tests for
coarrays.
2019-03-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/72714
* gfortran.dg/coarray_allocate_11.f90: New test.
[-- Attachment #2: p3.diff --]
[-- Type: text/x-patch, Size: 1833 bytes --]
Index: resolve.c
===================================================================
--- resolve.c (Revision 269260)
+++ resolve.c (Arbeitskopie)
@@ -7766,13 +7766,54 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code
if (codimension)
for (i = ar->dimen; i < ar->dimen + ar->codimen; i++)
- if (ar->dimen_type[i] == DIMEN_THIS_IMAGE)
- {
- gfc_error ("Coarray specification required in ALLOCATE statement "
- "at %L", &e->where);
- goto failure;
- }
+ {
+ switch (ar->dimen_type[i])
+ {
+ case DIMEN_THIS_IMAGE:
+ gfc_error ("Coarray specification required in ALLOCATE statement "
+ "at %L", &e->where);
+ goto failure;
+ case DIMEN_RANGE:
+ if (ar->start[i] == 0 || ar->end[i] == 0)
+ {
+ /* If ar->stride[i] is NULL, we issued a previous error. */
+ if (ar->stride[i] == NULL)
+ gfc_error ("Bad array specification in ALLOCATE statement "
+ "at %L", &e->where);
+ goto failure;
+ }
+ else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1)
+ {
+ gfc_error ("Upper cobound is less than lower cobound at %L",
+ &ar->start[i]->where);
+ goto failure;
+ }
+ break;
+
+ case DIMEN_ELEMENT:
+ if (ar->start[i]->expr_type == EXPR_CONSTANT)
+ {
+ gcc_assert (ar->start[i]->ts.type == BT_INTEGER);
+ if (mpz_cmp_si (ar->start[i]->value.integer, 1) < 0)
+ {
+ gfc_error ("Upper cobound is less than lower cobound "
+ " of 1 at %L", &ar->start[i]->where);
+ goto failure;
+ }
+ }
+ break;
+
+ case DIMEN_STAR:
+ break;
+
+ default:
+ gfc_error ("Bad array specification in ALLOCATE statement at %L",
+ &e->where);
+ goto failure;
+
+ }
+ }
for (i = 0; i < ar->dimen; i++)
{
if (ar->type == AR_ELEMENT || ar->type == AR_FULL)
[-- Attachment #3: coarray_allocate_11.f90 --]
[-- Type: text/x-fortran, Size: 833 bytes --]
! { dg-do compile }
! { dg-additional-options -fcoarray=single }
! PR fortran/72714
! Test for not ICEing and different error contitions when allocating
! coarrays.
program p
integer, allocatable :: z[:,:]
integer :: i
allocate (z[1:,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
allocate (z[:2,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
allocate (z[2:1,*]) ! { dg-error "Upper cobound is less than lower cobound" }
allocate (z[:0,*]) ! { dg-error "Bad array specification in ALLOCATE statement" }
allocate (z[0,*]) ! { dg-error "Upper cobound is less than lower cobound" }
allocate (z[1,*]) ! This is OK
allocate (z[1:1,*]) ! This is OK
allocate (z[i:i,*]) ! This is OK
allocate (z[i:i-1,*]) ! { dg-error "Upper cobound is less than lower cobound" }
end
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch, fortran] Fix PR 72714, ICE on invalid
2019-03-03 9:45 [patch, fortran] Fix PR 72714, ICE on invalid Thomas Koenig
@ 2019-03-03 13:07 ` Paul Richard Thomas
0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2019-03-03 13:07 UTC (permalink / raw)
To: Thomas Koenig; +Cc: fortran, gcc-patches
Hi Thomas,
This is good for trunk.
Thanks
Paul
On Sun, 3 Mar 2019 at 09:46, Thomas Koenig <tkoenig@netcologne.de> wrote:
>
> Hello world,
>
> the attached patch fixes a 7/8/9 regression by rejecting an invalid
> expression in coarray allocation that led to an ICE. It also adds a few
> more checks.
>
> One point that is checked for is that, unlike normal arrays, coarrays
> cannot be empty.
>
> Regression-tested. OK for trunk and affected branches?
>
> Regards
>
> Thomas
>
> 2019-03-02 Thomas Koenig <tkoenig@gcc.gnu.org>
>
>
>
> PR fortran/72714
>
> * resolve.c (resolve_allocate_expr): Add some tests for
> coarrays.
>
>
> 2019-03-02 Thomas Koenig <tkoenig@gcc.gnu.org>
>
>
>
> PR fortran/72714
>
> * gfortran.dg/coarray_allocate_11.f90: New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-03 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-03 9:45 [patch, fortran] Fix PR 72714, ICE on invalid Thomas Koenig
2019-03-03 13:07 ` Paul Richard Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).