This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, fortran] PR37926 - Program gives wrong output (connected to char len)
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 15 Nov 2008 07:44:15 +0100
- Subject: [Patch, fortran] PR37926 - Program gives wrong output (connected to char len)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=OubrBVTqcSHFcL1srzeMdQNtyxgNswOvQAn1rbrz8z4=; b=X8CsAuJ3MbcMlpsCLfB20PNWmoOdwhvriOZAndwIKOONPNOdTVCSE1kYpplqIciGfg GbIVs09uiKTBK6RyVUwy5ZS9C1P0DTJUfZJJmwGE4wwt6kPVsTkXGaHY6ca5y3qjAAB/ KuZBkKVXUlPqivOacmIAtH4Bjtz+ZeKhWOthQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=SibUhpf9AXiHSIk34HKxWd4ACi9Su5Py2Qhx22e/k/5Jpenz61FLlRxQE56Rem+epP qRrDo8DGq2KxkzYacpAEeOz/+1sL4515y6R2fbGJ4CuFLWcwCk0UF+FVORpwaW2wZXwb HVjkuLkyThE4bU5lPDExTlVBvxSqhPIHDLzNk=
Dear All,
This one verges on obvious, although it was a trifle testing to find -
'obvious after the even' perhaps?
Bootstrapped and regtested on FC9/x86_i64 - OK for trunk and 4.3?
Cheers
Paul
2008-11-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37926
* trans-expr.c (gfc_add_interface_mapping): Transfer the formal
arglist and the always_explicit attribute if the dummy arg is a
procedure.
2008-11-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37926
* gfortran.dg/dummy_procedure_3.f90: New test.
Index: gcc/testsuite/gfortran.dg/dummy_procedure_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dummy_procedure_3.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/dummy_procedure_3.f90 (revision 0)
@@ -0,0 +1,40 @@
+! { dg-do run }
+! PR37926 - the interface did not transfer the formal
+! argument list for the call to 'asz' in the specification of 'p'.
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+!
+module m
+contains
+ pure integer function mysize(a)
+ integer,intent(in) :: a(:)
+ mysize = size(a)
+ end function
+end module
+
+program prog
+ use m
+ implicit none
+ character(3) :: str
+ integer :: i(3) = (/1,2,3/)
+ str = p(i,mysize)
+ if (len(str) .ne. 3) call abort
+ if (str .ne. "BCD") call abort
+contains
+ function p(y,asz)
+ implicit none
+ integer :: y(:)
+ interface
+ pure integer function asz(c)
+ integer,intent(in) :: c(:)
+ end function
+ end interface
+ character(asz(y)) p
+ integer i
+ do i=1,asz(y)
+ p(i:i) = achar(iachar('A')+y(i))
+ end do
+ end function
+end
+! { dg-final { cleanup-modules "m" } }
+
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 141860)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -1711,6 +1711,15 @@
new_sym->attr.flavor = sym->attr.flavor;
new_sym->attr.function = sym->attr.function;
+ /* Ensure that the interface is available and that
+ descriptors are passed for array actual arguments. */
+ if (sym->attr.flavor == FL_PROCEDURE)
+ {
+ copy_formal_args (new_sym, expr->symtree->n.sym);
+ new_sym->attr.always_explicit
+ = expr->symtree->n.sym->attr.always_explicit;
+ }
+
/* Create a fake symtree for it. */
root = NULL;
new_symtree = gfc_new_symtree (&root, sym->name);