diff mbox series

[v2,fortran] PR fortran/90350 - ubound ICE on assumed size array even though explicit bound is specified

Message ID 3ba3c716-f607-6884-a729-fc6335dd4d9e@gmail.com
State New
Headers show
Series [v2,fortran] PR fortran/90350 - ubound ICE on assumed size array even though explicit bound is specified | expand

Commit Message

José Rui Faustino de Sousa April 21, 2020, 11:15 a.m. UTC
Hi again!

Proposed patch to Bug 90350 - ubound ICE on assumed size array even 
though explicit bound is specified

Patch tested only on x86_64-pc-linux-gnu.

Best regards,
José Rui

2020-4-19  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

  PR fortran/90350
  * simplify.c (simplify_bound): In the case of assumed-size arrays check
  if the reference is to a full array.

2020-4-19  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

  PR fortran/90350
  * PR90350.f90: New test.

Comments

Thomas Koenig April 21, 2020, 4:38 p.m. UTC | #1
Hi Jose,

> Proposed patch to Bug 90350 - ubound ICE on assumed size array even 
> though explicit bound is specified
> 
> Patch tested only on x86_64-pc-linux-gnu.
> 
> Best regards,
> José Rui

Looks good.

Do you have commit privileges? It not, I can commit it for you.

Regards

	Thomas
José Rui Faustino de Sousa April 22, 2020, 3:53 p.m. UTC | #2
Hi Thomas,

On 21/04/20 16:38, Thomas Koenig wrote:
> Do you have commit privileges? It not, I can commit it for you.
> 

No i do not. I would be grateful if you could.

Best regards,
José Rui
Thomas Koenig April 22, 2020, 4:22 p.m. UTC | #3
Hi Jose,


> On 21/04/20 16:38, Thomas Koenig wrote:
>> Do you have commit privileges? It not, I can commit it for you.
>>
> 
> No i do not. I would be grateful if you could.

Done, as 
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=808a6eadda1a353ce3a70556feac128580491b24 
.

Thanks a lot for the patch!

Regards

	Thomas
diff mbox series

Patch

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index c7a4f77..eb8b2af 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4157,6 +4157,7 @@  simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
 {
   gfc_ref *ref;
   gfc_array_spec *as;
+  ar_type type = AR_UNKNOWN;
   int d;
 
   if (array->ts.type == BT_CLASS)
@@ -4180,6 +4181,7 @@  simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
       switch (ref->type)
 	{
 	case REF_ARRAY:
+	  type = ref->u.ar.type;
 	  switch (ref->u.ar.type)
 	    {
 	    case AR_ELEMENT:
@@ -4233,7 +4235,7 @@  simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
       int k;
 
       /* UBOUND(ARRAY) is not valid for an assumed-size array.  */
-      if (upper && as && as->type == AS_ASSUMED_SIZE)
+      if (upper && type == AR_FULL && as && as->type == AS_ASSUMED_SIZE)
 	{
 	  /* An error message will be emitted in
 	     check_assumed_size_reference (resolve.c).  */
diff --git a/gcc/testsuite/gfortran.dg/PR90350.f90 b/gcc/testsuite/gfortran.dg/PR90350.f90
new file mode 100644
index 0000000..2e2cf10
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR90350.f90
@@ -0,0 +1,19 @@ 
+! { dg-do compile }
+!
+! Test the fix for PR90350
+!
+! Contributed by  <urbanjost@comcast.net>
+!
+
+program artificial
+implicit none
+integer :: arr(-10:10)
+   call asub(arr,size(arr))
+end program artificial
+subroutine asub(arr,n)
+integer,intent(in) :: arr(*)
+integer,intent(in) :: n
+   write(*,*)'UPPER=',ubound(arr(:n))
+   write(*,*)'LOWER=',lbound(arr(:n))
+   write(*,*)'SIZE=',size(arr(:n))
+end subroutine asub