diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2008-09-17 22:23:51 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2008-09-17 22:23:51 +0000 |
commit | 0b4e2af765d06ef7a49b7ad75cd205ea7c665819 (patch) | |
tree | 4541f82a616fe793fb7f6ddd9ad66a7cad888b0f /gcc/fortran/module.c | |
parent | c0b290997fa10dd3978c43c1dcdef8838fb15e98 (diff) | |
download | gcc-0b4e2af765d06ef7a49b7ad75cd205ea7c665819.zip gcc-0b4e2af765d06ef7a49b7ad75cd205ea7c665819.tar.gz gcc-0b4e2af765d06ef7a49b7ad75cd205ea7c665819.tar.bz2 |
re PR fortran/37274 ([Regression on 4.3?] error: type name is ambiguous.)
2008-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37274
PR fortran/36374
* module.c (check_for_ambiguous): New function to test loaded
symbol for ambiguity with fixup symbol.
(read_module): Call check_for_ambiguous.
(write_symtree): Do not write the symtree for symbols coming
from an interface body.
PR fortran/36374
* resolve.c (count_specific_procs ): New function to count the
number of specific procedures with the same name as the generic
and emit appropriate errors for and actual argument reference.
(resolve_assumed_size_actual): Add new argument no_formal_args.
Correct logic around passing generic procedures as arguments.
Call count_specific_procs from two locations.
(resolve_function): Evaluate and pass no_formal_args.
(resolve call): The same and clean up a bit by using csym more
widely.
PR fortran/36454
* symbol.c (gfc_add_access): Access can be updated if use
associated and not private.
2008-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37274
* gfortran.dg/used_types_22.f90: New test.
* gfortran.dg/used_types_23.f90: New test.
PR fortran/36374
* gfortran.dg/generic_17.f90: New test.
* gfortran.dg/ambiguous_specific_2.f90: New test.
* gfortran.dg/generic_actual_arg.f90: Add test for case that is
not ambiguous.
PR fortran/36454
* gfortran.dg/access_spec_3.f90: New test.
From-SVN: r140434
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 907002b..762114c 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -3944,6 +3944,48 @@ read_cleanup (pointer_info *p) } +/* It is not quite enough to check for ambiguity in the symbols by + the loaded symbol and the new symbol not being identical. */ +static bool +check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info) +{ + gfc_symbol *rsym; + module_locus locus; + symbol_attribute attr; + + rsym = info->u.rsym.sym; + if (st_sym == rsym) + return false; + + /* Identical derived types are not ambiguous and will be rolled up + later. */ + if (st_sym->attr.flavor == FL_DERIVED + && rsym->attr.flavor == FL_DERIVED + && gfc_compare_derived_types (st_sym, rsym)) + return false; + + /* If the existing symbol is generic from a different module and + the new symbol is generic there can be no ambiguity. */ + if (st_sym->attr.generic + && st_sym->module + && strcmp (st_sym->module, module_name)) + { + /* The new symbol's attributes have not yet been read. Since + we need attr.generic, read it directly. */ + get_module_locus (&locus); + set_module_locus (&info->u.rsym.where); + mio_lparen (); + attr.generic = 0; + mio_symbol_attribute (&attr); + set_module_locus (&locus); + if (attr.generic) + return false; + } + + return true; +} + + /* Read a module file. */ static void @@ -4085,7 +4127,7 @@ read_module (void) if (st != NULL) { /* Check for ambiguous symbols. */ - if (st->n.sym != info->u.rsym.sym) + if (check_for_ambiguous (st->n.sym, info)) st->ambiguous = 1; info->u.rsym.symtree = st; } @@ -4579,6 +4621,14 @@ write_symtree (gfc_symtree *st) pointer_info *p; sym = st->n.sym; + + /* A symbol in an interface body must not be visible in the + module file. */ + if (sym->ns != gfc_current_ns + && sym->ns->proc_name + && sym->ns->proc_name->attr.if_source == IFSRC_IFBODY) + return; + if (!gfc_check_access (sym->attr.access, sym->ns->default_access) || (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic && !sym->attr.subroutine && !sym->attr.function)) |