This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, fortran] PR30410 - Host association bug w/EXTERNAL
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 Jan 2007 10:06:43 +0100
- Subject: [Patch, fortran] PR30410 - Host association bug w/EXTERNAL
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=tAfgQY7s/EOTwItlVJz+1gR6DpePmCMz4dx8CpqAXTlLrXEAujDW9M7DMw3pGdxR+ibZrpQLJVv4AZq6VD8NfVHqFuDdoUj1qaI1ymLZrFKjRH0F5/1IPtJJ5J95PPXumxdim8rogsIgw/4q+CHmbZ870J0fenORWeVZxf9e0ow=
:ADDPATCH fortran:
Yes, I know, I know... but I could not resist this one-liner. It is
entirely self-explanatory - the testcase is the reporter's.
The strange thing is that nobody can have tried referencing a
use-associated, external procedure before. As far as I know, this
patch of code has not been touched for ~1 year.
Regtests on IA64/FC5 - OK for trunk and, after a week, for 4.1?
Paul
2007-01-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30410
* trans-decl.c (gfc_sym_mangled_function_id): Module, external
symbols must not have the module name prepended.
2007-01-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30410
* gfortran.dg/external_procedures_2.f90: New test.
Index: gcc/fortran/trans-decl.c
===================================================================
*** gcc/fortran/trans-decl.c (revision 120396)
--- gcc/fortran/trans-decl.c (working copy)
*************** gfc_sym_mangled_function_id (gfc_symbol
*** 315,321 ****
char name[GFC_MAX_MANGLED_SYMBOL_LEN + 1];
if (sym->module == NULL || sym->attr.proc == PROC_EXTERNAL
! || (sym->module != NULL && sym->attr.if_source == IFSRC_IFBODY))
{
if (strcmp (sym->name, "MAIN__") == 0
|| sym->attr.proc == PROC_INTRINSIC)
--- 315,322 ----
char name[GFC_MAX_MANGLED_SYMBOL_LEN + 1];
if (sym->module == NULL || sym->attr.proc == PROC_EXTERNAL
! || (sym->module != NULL && (sym->attr.external
! || sym->attr.if_source == IFSRC_IFBODY)))
{
if (strcmp (sym->name, "MAIN__") == 0
|| sym->attr.proc == PROC_INTRINSIC)
Index: gcc/testsuite/gfortran.dg/external_procedures_2.f90
===================================================================
*** gcc/testsuite/gfortran.dg/external_procedures_2.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/external_procedures_2.f90 (revision 0)
***************
*** 0 ****
--- 1,41 ----
+ ! { dg-do compile }
+ ! Tests the for PR30410, in which the reference to extfunc would
+ ! be incorrectly made to the module namespace.
+ !
+ ! Contributed by Harald Anlauf <anlauf@gmx.de>
+ !
+ module mod1
+ contains
+ function eval (func, x1)
+ real :: eval, func, x1
+ external :: func
+ eval = func (x1)
+ end function eval
+ end module mod1
+ !-------------------------------
+ module mod2
+ use mod1, only : eval
+ real, external :: extfunc ! This was referenced as __mod2__extfunc__
+ contains
+
+ subroutine foo (x0)
+ real :: x0, x1
+ x1 = 42
+ x0 = eval (extfunc, x1)
+ end subroutine foo
+
+ end module mod2
+ !-------------------------------
+ function extfunc (x)
+ real, intent(in) :: x
+ real :: extfunc
+ extfunc = x
+ end function extfunc
+ !-------------------------------
+ program gfcbug53
+ use mod2, only : foo
+ real :: x0 = 0
+ call foo (x0)
+ print *, x0
+ end program gfcbug53
+ ! { dg-final { cleanup-modules "mod1 mod2" } }