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

David Edelsohn dje@watson.ibm.com
Sat Jul 16 03:34:00 GMT 2005


	With the additional symbols and symtrees written to modules files,
the test for setting a symbol as ambiguous when reading a module file
allowed false positives.  With the earlier patches, the symtree symbol may
differ from the pointer info symbol because the pointer info symbol is
NULL.  This situation should not be considered a conflict causing the
ambiguous flag to be set.  Only a mismatch between valid symbol pointers
means ambiguous symbols.

	The first patch to write symtrees from contained namespaces
prevents the crash due to NULL symtree.  The second patch to write symbols
solves the Symbol not written error.  And this third patch to set
ambiguous more conservatively fixes ambiguous reference error messages in
the QUUS example.

David


	PR fortran/16861
	* module.c (read_module): Only set ambiguous if symtree and
	pointer info symbol both are set but do not match.
	(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	16 Jul 2005 02:58:23 -0000
*************** read_module (void)
*** 3096,3102 ****
  
        if (st != NULL)
  	{
! 	  if (st->n.sym != info->u.rsym.sym)
  	    st->ambiguous = 1;
            info->u.rsym.symtree = st;
  	}
--- 3096,3102 ----
  
        if (st != NULL)
  	{
! 	  if (st->n.sym != info->u.rsym.sym && info->u.rsym.sym != NULL)
  	    st->ambiguous = 1;
            info->u.rsym.symtree = st;
  	}
*************** 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