+2008-04-28 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35997
+ * module.c (find_symbol): Do not return a result for a symbol
+ that has been renamed in another module.
+
2008-04-26 George Helffrich <george@gcc.gnu.org>
PR fortran/35892
/* A recursive function to look for a speficic symbol by name and by
module. Whilst several symtrees might point to one symbol, its
is sufficient for the purposes here than one exist. Note that
- generic interfaces are distinguished. */
+ generic interfaces are distinguished as are symbols that have been
+ renamed in another module. */
static gfc_symtree *
find_symbol (gfc_symtree *st, const char *name,
const char *module, int generic)
{
int c;
- gfc_symtree *retval;
+ gfc_symtree *retval, *s;
if (st == NULL || st->n.sym == NULL)
return NULL;
&& strcmp (module, st->n.sym->module) == 0
&& !check_unique_name (st->name))
{
- if ((!generic && !st->n.sym->attr.generic)
- || (generic && st->n.sym->attr.generic))
+ s = gfc_find_symtree (gfc_current_ns->sym_root, name);
+
+ /* Detect symbols that are renamed by use association in another
+ module by the absence of a symtree and null attr.use_rename,
+ since the latter is not transmitted in the module file. */
+ if (((!generic && !st->n.sym->attr.generic)
+ || (generic && st->n.sym->attr.generic))
+ && !(s == NULL && !st->n.sym->attr.use_rename))
return st;
}
--- /dev/null
+! { dg-do compile }
+! Tests the fix for PR35997, in which the use association of renamed
+! valid2 and flag2 was treated as if the renaming were done on use
+! association in the main program. Thus, the following, direct use
+! association of valid and flag did not occur.
+!
+! Contributed by Drew McCormack <drewmccormack@mac.com>
+!
+module funcinterfacemod
+ interface
+ logical function valid ()
+ end function
+ end interface
+ logical :: flag = .true.
+end module
+
+module secondmod
+ use funcinterfacemod, valid2 => valid, flag2 => flag
+end module
+
+logical function valid ()
+ valid = .true.
+end function
+
+program main
+ use secondmod
+ use funcinterfacemod
+ if (valid ()) then
+ print *, 'Is Valid'
+ endif
+ if (flag) then
+ print *, 'Is flag'
+ endif
+end program
+! { dg-final { cleanup-modules "funcinterfacemod secondmod" } }