This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR34759 - Fix assumed-size check for intrinsic procedures


If  "A(4,4,*)" then  A and A(4,4,:)  are invalid for, e.g., SHAPE.
However, A(:,:,4) is a rank-2 array with known bounds.

Solution: We need to add a check whether we have the whole array;
"A(:,:,:)" is already rejected elsewhere.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias
2008-01-13  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34759
	* check.c (gfc_check_shape): Accept array ranges of
	assumed-size arrays.

2008-01-13  Tobias Burnus  <burnus@net-b.de>

	PR fortran/34759
	* gfortran.dg/assumed_size_refs_4.f90: New.

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(Revision 131501)
+++ gcc/fortran/check.c	(Arbeitskopie)
@@ -2394,7 +2394,7 @@ gfc_check_shape (gfc_expr *source)
 
   ar = gfc_find_array_ref (source);
 
-  if (ar->as && ar->as->type == AS_ASSUMED_SIZE)
+  if (ar->as && ar->as->type == AS_ASSUMED_SIZE && ar->type == AR_FULL)
     {
       gfc_error ("'source' argument of 'shape' intrinsic at %L must not be "
 		 "an assumed size array", &source->where);
Index: gcc/testsuite/gfortran.dg/assumed_size_refs_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/assumed_size_refs_4.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/assumed_size_refs_4.f90	(Revision 0)
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR fortran/34759
+! gfortran was before rejecting passing an assumed-size array
+! where the last dimension was specified.
+!
+! Test case provided by Dick Hendickson.
+!
+       subroutine j_assumed_size(A,N)
+       dimension A(10,11,12,*), k(3), l(3), m(4)
+       m = shape(A(:,:,:,:N)) ! OK
+       l = shape(A(:,:,:,3))  ! OK
+       m = shape(A(:,:,:,:))  ! { dg-error "upper bound of assumed size array" }
+       m = shape(A) ! { dg-error "must not be an assumed size array" }
+       end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]