RFC of importing of "IMPORT :: list-of-symbols"

Tobias Burnus burnus@net-b.de
Sat Nov 18 13:36:00 GMT 2006


Hi,

there are two kinds of imports possible:

First, "IMPORT" which imports all symbols and is done by essentially by
doing:
   if( IS_INTERFACE && !current_namelist->has_import_set)


Secondly, "IMPORT :: list-of-symbols". I currently do in decl.c's
gfc_match_import:

   gfc_find_symbol (name, gfc_current_ns->parent, 1, &sym)
   st = gfc_new_symtree (&gfc_current_ns->sym_root, name);
   st->n.sym = sym;
   sym->refs++;
   sym->ns = gfc_current_ns;

This works ok for programs, but fails for modules in trans-decl.c's
gfc_create_module_variable:
  /* Only output symbols from this module.  */
  if (sym->ns != module_namespace)
      /* I don't think this should ever happen.  */
      internal_error ("module symbol %s in wrong namespace", sym->name);

If I comment that condition, it seems to work without any problems, but
I'm not sure I do the right thing(TM).
Comments, better ideas? Can anyone dream up a situation where this does
not make sense?

Tobias

Attached: Test case, needs the commented condition in trans-decl.c
(gfc_create_module_variable) and my one-line fix for primary.c of
earlier today (http://gcc.gnu.org/ml/fortran/2006-11/msg00488.html).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: import4.f90
Type: text/x-fortran
Size: 1694 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20061118/6fde2f35/attachment.bin>


More information about the Fortran mailing list