Dear all, during the implementation of co_reduce in OpenCoarrays I noticed that GFortran passes a pointer to function instead of the function name to co_reduce.
Currently the compiler produces the following call: _gfortran_caf_co_reduce (&desc.0, &simple_reduction, 0, 0, 0B, 0B, 0, 0); where simple_reduction is the pure function that has to be used by co_reduce. The attached patch seems to fix the issue, any comments? Regards Alessandro PS: I also attach the test case
commit a12b6ce6993df109c81a32d5684b4b9f41f69ea4 Author: Alessandro Fanfarillo <fanfari...@ing.uniroma2.it> Date: Mon Jul 13 15:46:19 2015 +0200 Fix function pointer argument for co_reduce diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 66bc72a..967a741 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -8804,7 +8804,7 @@ conv_co_collective (gfc_code *code) } opr_flags = build_int_cst (integer_type_node, opr_flag_int); gfc_conv_expr (&argse, opr_expr); - opr = gfc_build_addr_expr (NULL_TREE, argse.expr); + opr = argse.expr; fndecl = build_call_expr_loc (input_location, fndecl, 8, array, opr, opr_flags, image_index, stat, errmsg, strlen, errmsg_len); }
program simple_reduce implicit none integer :: me me = this_image() sync all call co_reduce(me,simple_reduction) write(*,*) this_image(),me contains pure function simple_reduction(a,b) integer,intent(in) :: a,b integer :: simple_reduction simple_reduction = a * b end function simple_reduction end program simple_reduce