From: Tobias Burnus Date: Sat, 28 Jan 2012 10:59:18 +0000 (+0100) Subject: re PR fortran/52022 (Wrong-code with procedures passed as actual argument) X-Git-Tag: releases/gcc-4.5.4~250 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=283f1521d0f8b63fdda5db6de2f4ac719ca1a10e;p=thirdparty%2Fgcc.git re PR fortran/52022 (Wrong-code with procedures passed as actual argument) 2012-01-28 Tobias Burnus PR fortran/52022 * trans-expr.c (gfc_conv_procedure_call): Fix passing of functions, which return allocatables. 2012-01-28 Tobias Burnus PR fortran/52022 * gfortran.dg/dummy_procedure_7.f90: New. From-SVN: r183666 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e4298cca8327..627a5ee332fc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-01-28 Tobias Burnus + + PR fortran/52022 + * trans-expr.c (gfc_conv_procedure_call): Fix passing + of functions, which return allocatables. + 2011-10-13 Janus Weil PR fortran/50659 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index b3d49cc50d0b..f4d9fe11c6fd 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -3037,7 +3037,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && e->symtree->n.sym->attr.dummy)) || (e->expr_type == EXPR_VARIABLE && gfc_is_proc_ptr_comp (e, NULL)) - || fsym->attr.allocatable)) + || (fsym->attr.allocatable + && fsym->attr.flavor != FL_PROCEDURE))) { /* Scalar pointer dummy args require an extra level of indirection. The null pointer already contains diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b606a2604b00..69488199167b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-28 Tobias Burnus + + PR fortran/52022 + * gfortran.dg/dummy_procedure_7.f90: New. + 2012-01-21 Eric Botcazou * gnat.dg/renaming5.ad[sb]: New test. diff --git a/gcc/testsuite/gfortran.dg/dummy_procedure_7.f90 b/gcc/testsuite/gfortran.dg/dummy_procedure_7.f90 new file mode 100644 index 000000000000..32cd65ae8b66 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dummy_procedure_7.f90 @@ -0,0 +1,65 @@ +! { dg-do run } +! +! PR fortran/52022 +! + +module check + integer, save :: icheck = 0 +end module check + +module t +implicit none + contains +subroutine sol(cost) + use check + interface + function cost(p) result(y) + double precision,dimension(:) :: p + double precision,dimension(:),allocatable :: y + end function cost + end interface + + if (any (cost([1d0,2d0]) /= [2.d0, 4.d0])) call abort () + icheck = icheck + 1 +end subroutine + +end module t + +module tt + procedure(cost1),pointer :: pcost +contains + subroutine init() + pcost=>cost1 + end subroutine + + function cost1(x) result(y) + double precision,dimension(:) :: x + double precision,dimension(:),allocatable :: y + allocate(y(2)) + y=2d0*x + end function cost1 + + + + function cost(x) result(y) + double precision,dimension(:) :: x + double precision,dimension(:),allocatable :: y + allocate(y(2)) + y=pcost(x) + end function cost +end module + +program test + use tt + use t + use check + implicit none + + call init() + if (any (cost([3.d0,7.d0]) /= [6.d0, 14.d0])) call abort () + if (icheck /= 0) call abort () + call sol(cost) + if (icheck /= 1) call abort () +end program test + +! { dg-final { cleanup-modules "t tt check" } }