diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-03-28 14:01:57 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-03-28 14:01:57 +0100 |
commit | 3fb7f2fbd5f109786922deb5af8fd8dd594a7ba6 (patch) | |
tree | 1de04be18996b7af821d5b5d29dd86d0d484cac0 /gcc/fortran/decl.c | |
parent | 7981c06ae92548bd66f07121db1802eb6aec73ed (diff) | |
download | gcc-3fb7f2fbd5f109786922deb5af8fd8dd594a7ba6.zip gcc-3fb7f2fbd5f109786922deb5af8fd8dd594a7ba6.tar.gz gcc-3fb7f2fbd5f109786922deb5af8fd8dd594a7ba6.tar.bz2 |
[Fortran] Fix result-variable handling of MODULE PROCEDURE (PR94348)
PR fortran/94348
* decl.c (gfc_match_submod_proc): Add result var to the
proc's namespace.
PR fortran/94348
* gfortran.dg/module_procedure_3.f90: New.
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2f458c4..79c9510 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -9699,13 +9699,20 @@ gfc_match_submod_proc (void) if (get_proc_name (name, &sym, false)) return MATCH_ERROR; - /* Make sure that the result field is appropriately filled, even though - the result symbol will be replaced later on. */ + /* Make sure that the result field is appropriately filled. */ if (sym->tlink && sym->tlink->attr.function) { - if (sym->tlink->result - && sym->tlink->result != sym->tlink) - sym->result= sym->tlink->result; + if (sym->tlink->result && sym->tlink->result != sym->tlink) + { + sym->result = sym->tlink->result; + if (!sym->result->attr.use_assoc) + { + gfc_symtree *st = gfc_new_symtree (&gfc_current_ns->sym_root, + sym->result->name); + st->n.sym = sym->result; + sym->result->refs++; + } + } else sym->result = sym; } |