This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Fix PR 16485: Private entities from different modulescollide
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>
- Cc: patch <gcc-patches at gcc dot gnu dot org>, paul at codesourcery dot com
- Date: Thu, 02 Sep 2004 02:43:37 +0200
- Subject: Re: [gfortran] Fix PR 16485: Private entities from different modulescollide
- References: <40F417C6.70005@physik.uni-muenchen.de>
Tobias Schlüter wrote:
> We don't ensure that entities from different modules don't collide, e.g.
> module a
> private
> contains
> subroutine b
> end subroutine
> end
> module b
> private
> contains
> subroutine b
> end subroutine b
> end
> would yield an assembler error if both modules were contained in one
> file, and a linker error otherwise.
After extensive discussion with Paul on IRC, during which we found a bunch of
weird things both in gfortran and the standard, I created this revised patch.
It's quite late here, and I don't know if I'll have much time tomorrow, so I'm
posting this despite the high probability of messing up.
Built, new testcase attached. Ok if testsuite passes?
- Tobi
2004-09-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/16485
* parse.c (parse_contained): Make sure that private procedures
from modules have ACCESS_PRIVATE set.
* module.c (write_symbol): Don't fill in module name here.
(write_symbol0): Fill in here instead.
Index: module.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/module.c,v
retrieving revision 1.15
diff -u -p -r1.15 module.c
--- module.c 25 Aug 2004 21:18:35 -0000 1.15
+++ module.c 2 Sep 2004 00:30:51 -0000
@@ -3198,9 +3198,6 @@ write_symbol (int n, gfc_symbol * sym)
mio_integer (&n);
mio_internal_string (sym->name);
- if (sym->module[0] == '\0')
- strcpy (sym->module, module_name);
-
mio_internal_string (sym->module);
mio_pointer_ref (&sym->ns);
@@ -3226,6 +3223,8 @@ write_symbol0 (gfc_symtree * st)
write_symbol0 (st->right);
sym = st->n.sym;
+ if (sym->module[0] == '\0')
+ strcpy (sym->module, module_name);
if (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic
&& !sym->attr.subroutine && !sym->attr.function)
Index: parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/parse.c,v
retrieving revision 1.18
diff -u -p -r1.18 parse.c
--- parse.c 30 Aug 2004 19:08:38 -0000 1.18
+++ parse.c 2 Sep 2004 00:30:53 -0000
@@ -2218,6 +2218,8 @@ parse_contained (int module)
by other module functions. */
sym->attr.contained = 1;
sym->attr.referenced = 1;
+ if (module && sym->attr.access == ACCESS_UNKNOWN)
+ sym->attr.access = parent_ns->default_access;
parse_progunit (ST_NONE);
! { dg-do assemble }
module n
private u
contains
subroutine u
end subroutine u
end module n
module m
private :: u
contains
subroutine u
end subroutine u
end module m