Commit 3852e8b8 by Tobias Schlüter

re PR fortran/19673 (pointer function with RESULT specified returns pointer to…

re PR fortran/19673 (pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr")

fortran/
PR fortran/19673
* trans-expr.c (gfc_conv_function_call): Correctly dereference
argument from a pointer function also if it has a result clause.

testsuite/
PR fortran/19673
* gfortran.dg/func_result_1.f90: New test.

From-SVN: r95901
parent a873fcb4
Steven G. Kargl <kargls@comcast.net>
2005-03-04 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/19673
* trans-expr.c (gfc_conv_function_call): Correctly dereference
argument from a pointer function also if it has a result clause.
2005-03-04 Steven G. Kargl <kargls@comcast.net>
* expr.c (gfc_copy_shape_excluding): Change && to ||.
......
......@@ -1220,7 +1220,8 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
something like
x = f()
where f is pointer valued, we have to dereference the result. */
if (sym->attr.pointer && !se->want_pointer && !byref)
if (!se->want_pointer && !byref
&& (sym->attr.pointer || (sym->result && sym->result->attr.pointer)))
se->expr = gfc_build_indirect_ref (se->expr);
/* A pure function may still have side-effects - it may modify its
......
2005-03-04 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/19673
* gfortran.dg/func_result_1.f90: New test.
2005-03-04 Ben Elliston <bje@au.ibm.com>
* gcc.misc-tests/options.exp: New test.
......
! { dg-do run }
! From PR 19673 : We didn't dereference the the result from POINTER
! functions with a RESULT clause
program ret_ptr
if (foo(99) /= bar(99)) call abort ()
contains
function foo (arg) result(ptr)
integer :: arg
integer, pointer :: ptr
allocate (ptr)
ptr = arg
end function foo
function bar (arg)
integer :: arg
integer, pointer :: bar
allocate (bar)
bar = arg
end function bar
end program ret_ptr
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