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

2020-04-22 Thread Thomas Koenig via Gcc-patches

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


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

2020-04-22 Thread José Rui Faustino de Sousa via Gcc-patches

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



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

2020-04-21 Thread Thomas Koenig via Gcc-patches

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



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

2020-04-21 Thread José Rui Faustino de Sousa via Gcc-patches

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  

 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  

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

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 000..2e2cf10
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR90350.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! Test the fix for PR90350
+!
+! Contributed by  
+!
+
+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