]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Implement the F2018 reduce intrinsic [PR85836]
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 21 Mar 2025 16:20:21 +0000 (16:20 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 21 Mar 2025 16:20:21 +0000 (16:20 +0000)
commit94fa9f4d27bac577ecab43379a31fa28b146d6d9
tree2e7ceb188705afbc476c1fbbe33c8f5f6a2da781
parent1d2257dc850d088f6d9267b4624ba08533ab2475
Fortran:  Implement the F2018 reduce intrinsic [PR85836]

2025-03-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/85836
* check.cc (get_ul_from_cst_cl): New function used in
check_operation.
(check_operation): New function used in check_reduce and
check_co_reduce.
(gfc_check_co_reduce): Use it.
(gfc_check_reduce): New function.
(gfc_check_rename): Add prototype for intrinsic with 6 arguments.
* gfortran.h : Add isym id for reduce and prototype for f6.
* intrinsic.cc (do_check): Add another argument expression and use
it in the call to the six argument specific check.
(add_sym_6): New function.
(add_functions): Add the discription of the reduce intrinsic and
add it to the intrinsic list.
* intrinsic.h : Add prototypes for gfc_check_reduce and
gfc_resolve_reduce.
* iresolve.cc (generate_reduce_op_wrapper): Generate a wrapper
subroutine for the 'operation' function to enable the library
implementation to be type agnostic and use pointer arithmetic
throughout.
(gfc_resolve_reduce): New function.
* trans-expr.cc (gfc_conv_procedure_call): Add flag for scalar
reduce. Generate a return variable 'sr' for scalar reduce, pass its
address to the library function and return it as the scalar result.
* trans-intrinsic.cc (gfc_conv_intrinsic_function): Array valued
reduce is called in same way as reshape. Fall through for call to
the scalar version.

gcc/testsuite/
PR fortran/85836
* gfortran.dg/reduce_1.f90: New test
* gfortran.dg/reduce_2.f90: New test

libgfortran/
PR libfortran/85836
* Makefile.am : Add reduce.c
* Makefile.in : Regenerated
* gfortran.map : Add _gfortran_reduce, _gfortran_reduce_scalar,
_gfortran_reduce_c and _gfortran_reduce_scalar_c to the list.
* intrinsics/reduce.c (reduce, reduce_scalar, reduce_c,
reduce_scalar_c): New functions and prototypes
13 files changed:
gcc/fortran/check.cc
gcc/fortran/gfortran.h
gcc/fortran/intrinsic.cc
gcc/fortran/intrinsic.h
gcc/fortran/iresolve.cc
gcc/fortran/trans-expr.cc
gcc/fortran/trans-intrinsic.cc
gcc/testsuite/gfortran.dg/reduce_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/reduce_2.f90 [new file with mode: 0644]
libgfortran/Makefile.am
libgfortran/Makefile.in
libgfortran/gfortran.map
libgfortran/intrinsics/reduce.c [new file with mode: 0644]