From 3e1e5626dc66aa2bf4a2529b4aa842741d726340 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Mon, 1 Sep 2008 15:43:10 +0200 Subject: [PATCH] re PR fortran/37193 ("USE mod, ONLY: i, i=>j" does not import "i") 2008-09-01 Daniel Kraft PR fortran/37193 * module.c (read_module): Initialize use_only flag on used symbols. 2008-09-01 Daniel Kraft PR fortran/37193 * gfortran.dg/use_rename_4.f90: New test. * gfortran.dg/use_rename_5.f90: New test. From-SVN: r139866 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/module.c | 9 +++++++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/use_rename_4.f90 | 22 ++++++++++++++++++++++ gcc/testsuite/gfortran.dg/use_rename_5.f90 | 17 +++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/use_rename_4.f90 create mode 100644 gcc/testsuite/gfortran.dg/use_rename_5.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 92a0d35..516a974 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,10 @@ 2008-09-01 Daniel Kraft + PR fortran/37193 + * module.c (read_module): Initialize use_only flag on used symbols. + +2008-09-01 Daniel Kraft + * gfc-internals.texi (F2003 OOP), (Type-bound Procedures): New chapter and section to document the internals of type-bound procedures. (gfc_expr): Document EXPR_COMPCALL. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index c927803..907002b 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4094,9 +4094,9 @@ read_module (void) st = gfc_find_symtree (gfc_current_ns->sym_root, name); /* Delete the symtree if the symbol has been added by a USE - statement without an ONLY(11.3.2). Remember that the rsym + statement without an ONLY(11.3.2). Remember that the rsym will be the same as the symbol found in the symtree, for - this case.*/ + this case. */ if (st && (only_flag || info->u.rsym.renamed) && !st->n.sym->attr.use_only && !st->n.sym->attr.use_rename @@ -4132,6 +4132,11 @@ read_module (void) if (strcmp (name, p) != 0) sym->attr.use_rename = 1; + /* We need to set the only_flag here so that symbols from the + same USE...ONLY but earlier are not deleted from the tree in + the gfc_delete_symtree above. */ + sym->attr.use_only = only_flag; + /* Store the symtree pointing to this symbol. */ info->u.rsym.symtree = st; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 07830c8..44b789a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-09-01 Daniel Kraft + + PR fortran/37193 + * gfortran.dg/use_rename_4.f90: New test. + * gfortran.dg/use_rename_5.f90: New test. + 2008-09-01 Richard Guenther PR tree-optimization/37305 diff --git a/gcc/testsuite/gfortran.dg/use_rename_4.f90 b/gcc/testsuite/gfortran.dg/use_rename_4.f90 new file mode 100644 index 0000000..e0e83b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_rename_4.f90 @@ -0,0 +1,22 @@ +! { dg-do run } + +! PR fortran/37193 +! Check fix for problem with re-using the same symbol both renamed and +! plain. + +MODULE m + IMPLICIT NONE + INTEGER :: i +END MODULE m + +PROGRAM main + USE m, ONLY: i, j => i + IMPLICIT NONE + + i = 4 + j = 5 + + IF (i /= j) THEN + CALL abort () + END IF +END PROGRAM main diff --git a/gcc/testsuite/gfortran.dg/use_rename_5.f90 b/gcc/testsuite/gfortran.dg/use_rename_5.f90 new file mode 100644 index 0000000..3d7839a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_rename_5.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } + +! PR fortran/37193 +! Check that renamed symbols are not accessiable uner their target name. + +MODULE m + IMPLICIT NONE + INTEGER :: i +END MODULE m + +PROGRAM main + USE m, ONLY: j => i + IMPLICIT NONE + + i = 4 ! { dg-error "no IMPLICIT type" } + j = 5 +END PROGRAM main -- 2.7.4