From: Erik Edelmann Date: Thu, 9 Mar 2006 21:46:14 +0000 (+0000) Subject: trans-expr.c (gfc_add_interface_mapping): Copy 'allocatable' attribute from sym to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17029ac2c3a874073805f11941a7b5f888923d3a;p=gcc.git trans-expr.c (gfc_add_interface_mapping): Copy 'allocatable' attribute from sym to new_sym. fortran/ 2006-03-09 Erik Edelmann * 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 * gfortran.dg/allocatable_dummy_1.f90: Test for functions returning arrays too. From-SVN: r111910 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index dc1cdea6ec0..2e3d0f2479a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2006-03-09 Erik Edelmann + + * 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 PR fortran/26257 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 8c63b11b1a5..d1570a7dd2e 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 677fd313f4e..98ece81ed56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-03-09 Erik Edelmann + + * gfortran.dg/allocatable_dummy_1.f90: Test for functions returning + arrays too. + 2006-03-09 Diego Novillo * gcc/testsuite/g++.dg/gomp: New directory. diff --git a/gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 b/gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 index db65d71e6d8..bfa9ced010f 100644 --- a/gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 +++ b/gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 @@ -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