This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Subsections of assumed-size arrays have a known shape (PR30882)


:ADDPATCH fortran:

The shape/size for the assumed-size array dummy argument "integer ::
a(*)" is unkown. However, if one passes it as actual argument "a(1:10)"
to a procedure then its shape/size is known.

Found by Joost VandeVondele

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
Ok for the trunk, 4.2 and 4.1?

Tobias
2007-03-02  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/30882
	* check.c (dim_rank_check): The shape of subsections of
	assumed-size arrays is known.

2007-03-02  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/30882
	* gfortran.dg/size_dim.f90: New test.

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(Revision 122469)
+++ gcc/fortran/check.c	(Arbeitskopie)
@@ -337,7 +337,10 @@
 
   ar = gfc_find_array_ref (array);
   rank = array->rank;
-  if (ar->as->type == AS_ASSUMED_SIZE && !allow_assumed)
+  if (ar->as->type == AS_ASSUMED_SIZE
+      && !allow_assumed
+      && ar->type != AR_ELEMENT
+      && ar->type != AR_SECTION)
     rank--;
 
   if (mpz_cmp_ui (dim->value.integer, 1) < 0
Index: gcc/testsuite/gfortran.dg/size_dim.f90
===================================================================
--- gcc/testsuite/gfortran.dg/size_dim.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/size_dim.f90	(Revision 0)
@@ -0,0 +1,15 @@
+! { dg-do "run" }
+! Check size with initialization expression value for dim=
+! PR fortran/30882
+!
+! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
+!
+program main
+  integer :: a(10)
+  call S1(a)
+contains
+  subroutine S1(a)
+    integer :: a(*)
+    if(size(a(1:10),1) /= 10) call abort()
+  end subroutine S1
+end program main

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