diff mbox

[fortran] PR70071

Message ID 590B4819.3060503@gmx.de
State New
Headers show

Commit Message

Harald Anlauf May 4, 2017, 3:26 p.m. UTC
While trying to clean up my working copy, I found that the trivial
patch for the ICE-on-invalid as described in the PR regtests cleanly
for 7-release on i686-pc-linux-gnu.

Here's the cleaned-up version (diffs attached).


2017-05-04  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/70071
	* array.c (gfc_ref_dimen_size): Handle bad subscript triplets.



2017-05-04  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/70071
	* gfortran.dg/coarray_44.f90: New testcase.


If somebody wants to forward port this to 8-trunk, please go ahead.

Thanks,
Harald

Index: gcc/testsuite/gfortran.dg/coarray_44.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_44.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/coarray_44.f90	(revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! PR fortran/70071
+! Based on testcases by Gerhard Steinmetz
+
+program pr70071
+  implicit none
+  integer, allocatable :: z(:)[:,:]
+  allocate (z(2)[1::2,*])  ! { dg-error "Bad array dimension" }
+  allocate (z(1::2)[2,*])  ! { dg-error "Bad array specification in ALLOCATE" }
+end program pr70071

Comments

Steve Kargl May 4, 2017, 4:15 p.m. UTC | #1
On Thu, May 04, 2017 at 05:26:17PM +0200, Harald Anlauf wrote:
> While trying to clean up my working copy, I found that the trivial
> patch for the ICE-on-invalid as described in the PR regtests cleanly
> for 7-release on i686-pc-linux-gnu.
> 
> Here's the cleaned-up version (diffs attached).
> 
> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
> 
> 	PR fortran/70071
> 	* array.c (gfc_ref_dimen_size): Handle bad subscript triplets.
> 
> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
> 
> 	PR fortran/70071
> 	* gfortran.dg/coarray_44.f90: New testcase.
> 

Harald,

The patch looks reasonable.  Do you have a commit privilege?
Harald Anlauf May 4, 2017, 6:19 p.m. UTC | #2
On 05/04/17 18:15, Steve Kargl wrote:
> On Thu, May 04, 2017 at 05:26:17PM +0200, Harald Anlauf wrote:
>> While trying to clean up my working copy, I found that the trivial
>> patch for the ICE-on-invalid as described in the PR regtests cleanly
>> for 7-release on i686-pc-linux-gnu.
>>
>> Here's the cleaned-up version (diffs attached).
>>
>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>
>> 	PR fortran/70071
>> 	* array.c (gfc_ref_dimen_size): Handle bad subscript triplets.
>>
>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>
>> 	PR fortran/70071
>> 	* gfortran.dg/coarray_44.f90: New testcase.
>>
> 
> Harald,
> 
> The patch looks reasonable.  Do you have a commit privilege?
>

Steve,

no, I don't.

Would you like to take care of the patch?  Then please do so.

Thanks,
Harald
Harald Anlauf July 5, 2017, 6:44 p.m. UTC | #3
The patch below has not been applied to the best of my knowledge.

Just a reminder for whoever cares.

Harald

On 05/04/17 20:19, Harald Anlauf wrote:
> On 05/04/17 18:15, Steve Kargl wrote:
>> On Thu, May 04, 2017 at 05:26:17PM +0200, Harald Anlauf wrote:
>>> While trying to clean up my working copy, I found that the trivial
>>> patch for the ICE-on-invalid as described in the PR regtests cleanly
>>> for 7-release on i686-pc-linux-gnu.
>>>
>>> Here's the cleaned-up version (diffs attached).
>>>
>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>
>>> 	PR fortran/70071
>>> 	* array.c (gfc_ref_dimen_size): Handle bad subscript triplets.
>>>
>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>
>>> 	PR fortran/70071
>>> 	* gfortran.dg/coarray_44.f90: New testcase.
>>>
>>
>> Harald,
>>
>> The patch looks reasonable.  Do you have a commit privilege?
>>
> 
> Steve,
> 
> no, I don't.
> 
> Would you like to take care of the patch?  Then please do so.
> 
> Thanks,
> Harald
>
Janus Weil July 5, 2017, 8:03 p.m. UTC | #4
Hi Harald,

thanks for the reminder. I can take care of committing the patch for
you. Just give me a day or two ...

Cheers,
Janus



2017-07-05 20:44 GMT+02:00 Harald Anlauf <anlauf@gmx.de>:
> The patch below has not been applied to the best of my knowledge.
>
> Just a reminder for whoever cares.
>
> Harald
>
> On 05/04/17 20:19, Harald Anlauf wrote:
>> On 05/04/17 18:15, Steve Kargl wrote:
>>> On Thu, May 04, 2017 at 05:26:17PM +0200, Harald Anlauf wrote:
>>>> While trying to clean up my working copy, I found that the trivial
>>>> patch for the ICE-on-invalid as described in the PR regtests cleanly
>>>> for 7-release on i686-pc-linux-gnu.
>>>>
>>>> Here's the cleaned-up version (diffs attached).
>>>>
>>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>>
>>>>     PR fortran/70071
>>>>     * array.c (gfc_ref_dimen_size): Handle bad subscript triplets.
>>>>
>>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>>
>>>>     PR fortran/70071
>>>>     * gfortran.dg/coarray_44.f90: New testcase.
>>>>
>>>
>>> Harald,
>>>
>>> The patch looks reasonable.  Do you have a commit privilege?
>>>
>>
>> Steve,
>>
>> no, I don't.
>>
>> Would you like to take care of the patch?  Then please do so.
>>
>> Thanks,
>> Harald
>>
>
Janus Weil July 6, 2017, 7:50 p.m. UTC | #5
Applied to trunk as r250039. Thanks for the patch!

Cheers,
Janus

2017-07-05 22:03 GMT+02:00 Janus Weil <janus@gcc.gnu.org>:
> Hi Harald,
>
> thanks for the reminder. I can take care of committing the patch for
> you. Just give me a day or two ...
>
> Cheers,
> Janus
>
>
>
> 2017-07-05 20:44 GMT+02:00 Harald Anlauf <anlauf@gmx.de>:
>> The patch below has not been applied to the best of my knowledge.
>>
>> Just a reminder for whoever cares.
>>
>> Harald
>>
>> On 05/04/17 20:19, Harald Anlauf wrote:
>>> On 05/04/17 18:15, Steve Kargl wrote:
>>>> On Thu, May 04, 2017 at 05:26:17PM +0200, Harald Anlauf wrote:
>>>>> While trying to clean up my working copy, I found that the trivial
>>>>> patch for the ICE-on-invalid as described in the PR regtests cleanly
>>>>> for 7-release on i686-pc-linux-gnu.
>>>>>
>>>>> Here's the cleaned-up version (diffs attached).
>>>>>
>>>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>>>
>>>>>     PR fortran/70071
>>>>>     * array.c (gfc_ref_dimen_size): Handle bad subscript triplets.
>>>>>
>>>>> 2017-05-04  Harald Anlauf  <anlauf@gmx.de>
>>>>>
>>>>>     PR fortran/70071
>>>>>     * gfortran.dg/coarray_44.f90: New testcase.
>>>>>
>>>>
>>>> Harald,
>>>>
>>>> The patch looks reasonable.  Do you have a commit privilege?
>>>>
>>>
>>> Steve,
>>>
>>> no, I don't.
>>>
>>> Would you like to take care of the patch?  Then please do so.
>>>
>>> Thanks,
>>> Harald
>>>
>>
diff mbox

Patch

Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c	(revision 247015)
+++ gcc/fortran/array.c	(working copy)
@@ -2202,9 +2202,15 @@  gfc_ref_dimen_size (gfc_array_ref *ar, int dimen,
   mpz_t diff;
   bool t;
 
-  if (dimen < 0 || ar == NULL || dimen > ar->dimen - 1)
+  if (dimen < 0 || ar == NULL)
     gfc_internal_error ("gfc_ref_dimen_size(): Bad dimension");
 
+  if (dimen > ar->dimen - 1)
+    {
+      gfc_error ("Bad array dimension at %L", &ar->c_where[dimen]);
+      return false;
+    }
+
   switch (ar->dimen_type[dimen])
     {
     case DIMEN_ELEMENT: