Commit a01db3bf by Erik Edelmann

re PR fortran/22607 (Elemental character functions don't work)

fortran/
2005-11-09  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/22607
        * trans-decl.c(build_function_decl): Don't set
        DECL_IS_PURE (fndecl) = 1 for return-by-reference
        functions.

testsuite/
2005-11-09  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/22607
        * gfortran-dg/pure_byref_1.f90: New.
        * gfortran-dg/pure_byref_2.f90: New.

From-SVN: r106683
parent 1508cc46
2005-11-09 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* trans-decl.c(build_function_decl): Don't set
DECL_IS_PURE (fndecl) = 1 for return-by-reference
functions.
2005-11-08 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* dump-parse-tree.c: Fix comment typo, add a few blank lines.
......
......@@ -1203,7 +1203,7 @@ build_function_decl (gfc_symbol * sym)
/* TODO: check if a pure SUBROUTINE has no INTENT(OUT) arguments
including a alternate return. In that case it can also be
marked as PURE. See also in gfc_get_extern_function_decl(). */
if (attr.function)
if (attr.function && !gfc_return_by_reference (sym))
DECL_IS_PURE (fndecl) = 1;
TREE_SIDE_EFFECTS (fndecl) = 0;
}
......
2005-11-09 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* gfortran-dg/pure_byref_1.f90: New.
* gfortran-dg/pure_byref_2.f90: New.
2005-11-09 Uros Bizjak <uros@kss-loka.si>
PR c/24101
! { dg-do run }
! PR 22607: PURE/ELEMENTAL return-by-reference functions
program main
implicit none
character(2), dimension(2) :: a, b
a = 'ok'
b = fun(a)
if (.not.all(b == 'ok')) call abort()
contains
elemental function fun(a)
character(*), intent(in) :: a
character(len(a)) :: fun
fun = a
end function fun
end program main
! { dg-do run }
! PR 22607: PURE return-by-reference functions
program main
implicit none
integer, dimension(2) :: b
b = fun(size(b))
if (b(1) /= 1 .or. b(2) /= 2) call abort()
contains
pure function fun(n)
integer, intent(in) :: n
integer :: fun(n)
integer :: i
do i = 1, n
fun(i) = i
end do
end function fun
end program main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment