re PR fortran/38594 (module function name mangled improperly if contained function of same name exists)

2009-01-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38594
	* resolve.c (resolve_call): When searching for proper host
	association, use symtree rather than symbol.  For everything
	except generic subroutines, substitute the symtree in the call
	rather than the symbol.

2009-01-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38594
	* gfortran.dg/host_assoc_call_3.f90: Make sure that the generic
	interface still works, in addition to original tests.
	* gfortran.dg/host_assoc_call_6.f90: New test.

From-SVN: r143032
This commit is contained in:
Paul Thomas 2009-01-03 17:47:20 +00:00
parent 493aa551b2
commit 79b1d36cdd
6 changed files with 4192 additions and 4137 deletions

File diff suppressed because it is too large Load Diff

4135
gcc/fortran/ChangeLog-2008 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2944,15 +2944,20 @@ resolve_call (gfc_code *c)
if (csym && gfc_current_ns->parent && csym->ns != gfc_current_ns)
{
gfc_find_symbol (csym->name, gfc_current_ns, 1, &sym);
gfc_symtree *st;
gfc_find_sym_tree (csym->name, gfc_current_ns, 1, &st);
sym = st ? st->n.sym : NULL;
if (sym && csym != sym
&& sym->ns == gfc_current_ns
&& sym->attr.flavor == FL_PROCEDURE
&& sym->attr.contained)
{
sym->refs++;
csym = sym;
c->symtree->n.sym = sym;
if (csym->attr.generic)
c->symtree->n.sym = sym;
else
c->symtree = st;
csym = c->symtree->n.sym;
}
}

View File

@ -1,3 +1,10 @@
2009-01-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38594
* gfortran.dg/host_assoc_call_3.f90: Make sure that the generic
interface still works, in addition to original tests.
* gfortran.dg/host_assoc_call_6.f90: New test.
2009-01-03 Jakub Jelinek <jakub@redhat.com>
PR c++/38705

View File

@ -11,8 +11,10 @@ MODULE M1
END INTERFACE
CONTAINS
SUBROUTINE S1(I)
i = 3
END SUBROUTINE
SUBROUTINE S2(F)
f = 4.0
END SUBROUTINE
END MODULE
@ -36,9 +38,18 @@ CONTAINS
end if
END SUBROUTINE
END SUBROUTINE
subroutine S4
integer :: check = 0
REAL :: rcheck = 0.0
call putaline(check)
if (check .ne. 3) call abort
call putaline(rcheck)
if (rcheck .ne. 4.0) call abort
end subroutine s4
END MODULE
USE M2
CALL S3
call S4
END
! { dg-final { cleanup-modules "M1 M2" } }

View File

@ -0,0 +1,25 @@
! { dg-do compile }
!
! PR fortran/38594, in which the symtree for the first
! 'g' was being attached to the second. This is necessary
! for generic interfaces(eg. hosts_call_3.f90) but makes
! a mess otherwise.
!
! Contributed by Daniel Franke <dfranke@gcc.gnu.org>
!
MODULE m
CONTAINS
SUBROUTINE g()
END SUBROUTINE
SUBROUTINE f()
CALL g()
CONTAINS
SUBROUTINE g()
END SUBROUTINE
END SUBROUTINE
END MODULE
USE m
CALL g()
END
! { dg-final { cleanup-modules "m" } }