[PATCH] fortran/15976

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Nov 10 16:56:00 GMT 2005


On Thu, Nov 10, 2005 at 10:13:20AM +0100, THOMAS Paul Richard 169137 wrote:
> A point of order, chaps...
> 
> Whilst we all think that the patch is correct, this should be copied to the
> list.
> 
> Paul
> 
> > -----Message d'origine-----
> > De : Tobias.Schlueter@Physik.Uni-Muenchen.DE
> > [mailto:Tobias.Schlueter@Physik.Uni-Muenchen.DE]
> > Envoy? : mercredi 9 novembre 2005 20:49
> > ? : Steve Kargl
> > Cc : THOMAS Paul Richard 169137; 'Tobias Schl?ter'
> > Objet : Re: [PATCH] fortran/15976
> > 
> > Quoting Steve Kargl <sgk@troutmask.apl.washington.edu>:
> > > The attached patch has been bootstrapped and regression tested
> > > on i386-*-freebsd and amd64-*-freebsd.  Okay for mainline and
> > > 4.0.
> > 
> > Yes.
> > 
> > - Tobi

<note to self> Learn to read header prior to sending </note to self>

I will commit the attached patch and test case in approximately
8 hours based on Tobi's approval unless someone has some objections.

The attached patch has been bootstrapped and regression tested
on i386-*-freebsd and amd64-*-freebsd.  Okay for mainline and
4.0.
  
2005-11-9  Paul Thomas  <pault@gcc.gnu.org>
           Steven G. Kargl <kargls@comcast.net>
  
        * resolve.c (resolve_symbol): Disallow automatic arrays in module scope.
 
 
2005-11-9  Paul Thomas  <pault@gcc.gnu.org>
 
        * gfortran.dg/automatic_module_variable.f90: New test.

-- 
Steve
-------------- next part --------------
Index: resolve.c
===================================================================
--- resolve.c	(revision 106708)
+++ resolve.c	(working copy)
@@ -4282,6 +4282,22 @@ resolve_symbol (gfc_symbol * sym)
 	  return;
     }
 
+  /* A module array's shape needs to be constant.  */
+
+  if (sym->ns->proc_name
+      && sym->attr.flavor == FL_VARIABLE
+      && sym->ns->proc_name->attr.flavor == FL_MODULE
+      && !sym->attr.use_assoc
+      && !sym->attr.allocatable
+      && !sym->attr.pointer
+      && sym->as != NULL
+      && !gfc_is_compile_time_shape (sym->as))
+    {
+      gfc_error ("Module array '%s' at %L cannot be automatic "
+         "or assumed shape", sym->name, &sym->declared_at);
+      return;
+    }
+
   /* Make sure that character string variables with assumed length are
      dummy arguments.  */
 
@@ -4465,7 +4481,7 @@ resolve_symbol (gfc_symbol * sym)
   switch (sym->attr.flavor)
     {
     case FL_VARIABLE:
-      /* Can the sybol have an initializer?  */
+      /* Can the symbol have an initializer?  */
       flag = 0;
       if (sym->attr.allocatable || sym->attr.external || sym->attr.dummy
 	  || sym->attr.intrinsic || sym->attr.result)
-------------- next part --------------
! { dg-do compile }
! Tests fix for PR15976
!
module sd
  integer, parameter :: n = 20
  integer :: i(n)
  integer :: j(m) ! { dg-error "cannot be automatic or assumed shape" }
  integer, pointer :: p(:)
  integer, allocatable :: q(:)
contains
  function init (x, l)
    integer :: x(l)
    integer :: init(l)
    init = x
  end function init
end module sd


More information about the Fortran mailing list