]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/52022 (Wrong-code with procedures passed as actual argument)
authorTobias Burnus <burnus@net-b.de>
Sat, 28 Jan 2012 10:00:13 +0000 (11:00 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 28 Jan 2012 10:00:13 +0000 (11:00 +0100)
2012-01-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52022
        * trans-expr.c (gfc_conv_procedure_call): Fix passing
        of functions, which return allocatables.

2012-01-28  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52022
        * gfortran.dg/dummy_procedure_7.f90: New.

From-SVN: r183665

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dummy_procedure_7.f90 [new file with mode: 0644]

index ebdcbc08d9c85e3f85823388e78294b2bf98d553..54bc970688beb46a8c6079522cacdb623fb402e7 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-28  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/52022
+       * trans-expr.c (gfc_conv_procedure_call): Fix passing
+       of functions, which return allocatables.
+
 2012-01-25  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/51966
index 773b2c62db7e20d3c5c425f9f881f128e983c5ce..0eec9cee92d2c4188d5819625df2056c9e66eee4 100644 (file)
@@ -3064,7 +3064,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                          || (fsym->attr.proc_pointer
                              && 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
index 97e7d779ce3539ed62aa8b07200346dc9fcdeb55..82c0a6bd110ed854afc9a0499e6a52d4d8327276 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-28  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/52022
+       * gfortran.dg/dummy_procedure_7.f90: New.
+
 2012-01-25  Jason Merrill  <jason@redhat.com>
 
        PR target/51934
diff --git a/gcc/testsuite/gfortran.dg/dummy_procedure_7.f90 b/gcc/testsuite/gfortran.dg/dummy_procedure_7.f90
new file mode 100644 (file)
index 0000000..32cd65a
--- /dev/null
@@ -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" } }