Commit 3fb7f2fb by Tobias Burnus

[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.
parent 7981c06a
2020-03-28 Tobias Burnus <tobias@codesourcery.com>
PR fortran/94348
* decl.c (gfc_match_submod_proc): Add result var to the
proc's namespace.
2020-03-27 Tobias Burnus <tobias@codesourcery.com> 2020-03-27 Tobias Burnus <tobias@codesourcery.com>
PR fortran/93957 PR fortran/93957
......
...@@ -9699,13 +9699,20 @@ gfc_match_submod_proc (void) ...@@ -9699,13 +9699,20 @@ gfc_match_submod_proc (void)
if (get_proc_name (name, &sym, false)) if (get_proc_name (name, &sym, false))
return MATCH_ERROR; return MATCH_ERROR;
/* Make sure that the result field is appropriately filled, even though /* Make sure that the result field is appropriately filled. */
the result symbol will be replaced later on. */
if (sym->tlink && sym->tlink->attr.function) if (sym->tlink && sym->tlink->attr.function)
{ {
if (sym->tlink->result if (sym->tlink->result && sym->tlink->result != sym->tlink)
&& sym->tlink->result != sym->tlink) {
sym->result= sym->tlink->result; 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 else
sym->result = sym; sym->result = sym;
} }
......
2020-03-28 Tobias Burnus <tobias@codesourcery.com>
PR fortran/94348
* gfortran.dg/module_procedure_3.f90: New.
2020-03-28 Patrick Palka <ppalka@redhat.com> 2020-03-28 Patrick Palka <ppalka@redhat.com>
PR c++/94306 PR c++/94306
......
! { dg-do run }
!
! PR fortran/94348
!
! Contributed by Damian Rouson
module foo_module
implicit none
interface
module function foo() result(bar)
implicit none
integer bar
end function
end interface
contains
module procedure foo
bar = 5
end procedure
end module
program main
use foo_module
implicit none
if (foo() /= 5) stop 1
end program main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment