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

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


	And this updated patch to walk all namespaces to write both
symbols and symtrees fixes the "Symbol not written" problem.

	We're back to the issue of not duplicating output of symtrees.
Maybe this needs to use the same marking approach as write_symbol0.

David


	PR fortran/16861
	* module.c (write_symtree): Skip MODULE symbols.
	(walk_namespaces): New.
	(write_module): Use it to write symbols and symtrees.

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 19:13:57 -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_namespaces (gfc_namespace * ns, void (*func) (gfc_symtree *))
+ {
+   gfc_traverse_symtree (ns->sym_root, func);
+ 
+   for (ns = ns->contained; ns; ns = ns->sibling)
+     walk_namespaces (ns, func);
+ }
+ 
+ 
+ static void
  write_module (void)
  {
    gfc_intrinsic_op i;
*************** write_module (void)
*** 3458,3464 ****
  
    mio_lparen ();
  
!   write_symbol0 (gfc_current_ns->sym_root);
    while (write_symbol1 (pi_root));
  
    mio_rparen ();
--- 3469,3475 ----
  
    mio_lparen ();
  
!   walk_namespaces (gfc_current_ns, write_symbol0);
    while (write_symbol1 (pi_root));
  
    mio_rparen ();
*************** 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_namespaces (gfc_current_ns, write_symtree);
    mio_rparen ();
  }
  



More information about the Fortran mailing list