[RFC, fortran] Output contained namespaces in module (PR fortran/16861)

David Edelsohn dje@watson.ibm.com
Fri Jul 15 19:11:00 GMT 2005


>>>>> Paul Thomas writes:

Paul> Bizarrely, you have turned the ICE in pr16940 into a, well... ,
enigmatic: 

Paul> In file pr16940.f90:19

Paul> end module Max_Loc_Mod
Paul> 1
Paul> Internal Error at (1):
Paul> write_symtree(): Symbol not written

Paul> which persists, even when the workaround, described in the pr, is
deployed.

	The updated patch that actually walks the namespace, attached in
the PR, is appended.

	I am investigating the "Symbol not written" error.  I suspect the
problem is that there are more namespace traversals not walking contained
namespaces.  When gfortran writes the symtrees in all namespaces contained
in the module, the underlying symbols are discovered not to have been
written.

David


	PR fortran/16861
	* module.c (write_symtree): Skip MODULE symbols.
	(walk_namespace_symtree): New.
	(write_module): Use it.

Index: module.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/module.c,v
retrieving revision 1.34
diff -c -p -r1.34 module.c
*** module.c	25 Jun 2005 00:40:35 -0000	1.34
--- module.c	15 Jul 2005 16:17:59 -0000
*************** write_symtree (gfc_symtree * st)
*** 3393,3399 ****
    sym = st->n.sym;
    if (!gfc_check_access (sym->attr.access, sym->ns->default_access)
        || (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic
! 	  && !sym->attr.subroutine && !sym->attr.function))
      return;
  
    if (check_unique_name (st->name))
--- 3393,3400 ----
    sym = st->n.sym;
    if (!gfc_check_access (sym->attr.access, sym->ns->default_access)
        || (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic
! 	  && !sym->attr.subroutine && !sym->attr.function)
!       || (sym->attr.flavor == FL_MODULE))
      return;
  
    if (check_unique_name (st->name))
*************** write_symtree (gfc_symtree * st)
*** 3410,3415 ****
--- 3411,3426 ----
  
  
  static void
+ walk_namespace_symtree (gfc_namespace * ns, void (*func) (gfc_symtree *))
+ {
+   gfc_traverse_symtree (ns->sym_root, func);
+ 
+   for (ns = ns->contained; ns; ns = ns->sibling)
+     walk_namespace_symtree (ns, func);
+ }
+ 
+ 
+ static void
  write_module (void)
  {
    gfc_intrinsic_op i;
*************** write_module (void)
*** 3467,3473 ****
    write_char ('\n');
  
    mio_lparen ();
!   gfc_traverse_symtree (gfc_current_ns->sym_root, write_symtree);
    mio_rparen ();
  }
  
--- 3478,3484 ----
    write_char ('\n');
  
    mio_lparen ();
!   walk_namespace_symtree (gfc_current_ns, write_symtree);
    mio_rparen ();
  }
  



More information about the Fortran mailing list