trans-expr.c (gfc_add_interface_mapping): Copy 'allocatable' attribute from sym to...
authorErik Edelmann <eedelman@gcc.gnu.org>
Thu, 9 Mar 2006 21:46:14 +0000 (21:46 +0000)
committerErik Edelmann <eedelman@gcc.gnu.org>
Thu, 9 Mar 2006 21:46:14 +0000 (21:46 +0000)
fortran/
2006-03-09  Erik Edelmann  <eedelman@gcc.gnu.org>

        * trans-expr.c (gfc_add_interface_mapping): Copy 'allocatable'
        attribute from sym to new_sym.  Call build_fold_indirect_ref()
        for allocatable arguments.

testsuite/
2006-03-09  Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/allocatable_dummy_1.f90: Test for functions returning
        arrays too.

From-SVN: r111910

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90

index dc1cdea6ec0b6999c2ff0cca704a13d44c78fbde..2e3d0f2479a2126fcd3c2ac89a0c16b12e23bc9f 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-09  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       * trans-expr.c (gfc_add_interface_mapping): Copy 'allocatable'
+       attribute from sym to new_sym.  Call build_fold_indirect_ref()
+       for allocatable arguments.
+
 2006-03-09 Paul Thomas <pault@gcc.gnu.org>
 
        PR fortran/26257
index 8c63b11b1a510bb19378621023abcc3fbe85a532..d1570a7dd2ebcc282283c224a5d7e73cdaa4f838 100644 (file)
@@ -1316,6 +1316,7 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping,
   new_sym->attr.referenced = 1;
   new_sym->attr.dimension = sym->attr.dimension;
   new_sym->attr.pointer = sym->attr.pointer;
+  new_sym->attr.allocatable = sym->attr.allocatable;
   new_sym->attr.flavor = sym->attr.flavor;
 
   /* Create a fake symtree for it.  */
@@ -1367,8 +1368,9 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping,
        value = build_fold_indirect_ref (value);
     }
 
-  /* If the argument is a scalar or a pointer to an array, dereference it.  */
-  else if (!sym->attr.dimension || sym->attr.pointer)
+  /* If the argument is a scalar, a pointer to an array or an allocatable,
+     dereference it.  */
+  else if (!sym->attr.dimension || sym->attr.pointer || sym->attr.allocatable)
     value = build_fold_indirect_ref (se->expr);
   
   /* For character(*), use the actual argument's descriptor.  */  
index 677fd313f4eca7b1bf195a0317b2817879f807a9..98ece81ed56d17d44ba92919ad00fafae4fd65a6 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-09  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       * gfortran.dg/allocatable_dummy_1.f90: Test for functions returning
+       arrays too.
+
 2006-03-09  Diego Novillo  <dnovillo@redhat.com>
 
         * gcc/testsuite/g++.dg/gomp: New directory.
index db65d71e6d83615112487252b2f2d4e2c4c97513..bfa9ced010f117c5eb9a1cc762ad1717bc3f20df 100644 (file)
@@ -13,6 +13,8 @@ program alloc_dummy
     call useit(a, b)
     if (.NOT.all(b == [ 1, 2, 3 ])) call abort()
 
+    if (.NOT.all(whatever(a) == [ 1, 2, 3 ])) call abort()
+
     call kill(a)
     if (allocated(a)) call abort()
 
@@ -35,6 +37,13 @@ contains
         y = x
     end subroutine useit
 
+    function whatever(x)
+        integer, allocatable :: x(:)
+        integer :: whatever(size(x))
+        
+        whatever = x
+    end function whatever
+
     subroutine kill(x)
         integer, allocatable, intent(out) :: x(:)
     end subroutine kill