aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2008-04-30 20:13:21 +0000
committerPaul Thomas <pault@gcc.gnu.org>2008-04-30 20:13:21 +0000
commit29d40637c45caf4b5ed5a9c4ce651a3623f13466 (patch)
tree5eda8593c6924f553e42fef0fc3d4f1b0053a1f8 /gcc
parentad516a74de3fede4d52dcd3b8aeb65aa148e14e3 (diff)
downloadgcc-29d40637c45caf4b5ed5a9c4ce651a3623f13466.zip
gcc-29d40637c45caf4b5ed5a9c4ce651a3623f13466.tar.gz
gcc-29d40637c45caf4b5ed5a9c4ce651a3623f13466.tar.bz2
re PR fortran/35997 (Used function interface bug)
2008-04-30 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-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/35997 * gfortran.dg/use_rename_3.f90 From-SVN: r134836
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/module.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/use_rename_3.f9035
4 files changed, 57 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 84e8f7b..13fb052 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index bc45e9e..832f686 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -3146,13 +3146,14 @@ find_symtree_for_symbol (gfc_symtree *st, gfc_symbol *sym)
/* 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;
@@ -3162,8 +3163,14 @@ find_symbol (gfc_symtree *st, const char *name,
&& 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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 410b720..ca56282 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-28 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35997
+ * gfortran.dg/use_rename_3.f90
+
2008-04-30 Richard Guenther <rguenther@suse.de>
PR tree-optimization/21636
diff --git a/gcc/testsuite/gfortran.dg/use_rename_3.f90 b/gcc/testsuite/gfortran.dg/use_rename_3.f90
new file mode 100644
index 0000000..9f28e2e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/use_rename_3.f90
@@ -0,0 +1,35 @@
+! { 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" } }