[PATCH 2/2] fortran: Ignore unused args in scalarization [PR97896]

Mikael Morin mikael@gcc.gnu.org
Sun Nov 7 16:17:46 GMT 2021


The KIND argument of the INDEX intrinsic is a compile time constant
that is used at compile time only to resolve to a kind-specific library
function.  That argument is otherwise completely ignored at runtime, and there is
no code generated for it as the library procedure has no kind argument.
This confuses the scalarizer which expects to see every argument
of elemental functions used when calling a procedure.
This change removes the argument from the scalarization lists
at the beginning of the scalarization process, so that the argument
is completely ignored.

	PR fortran/97896

gcc/fortran/ChangeLog:
	* trans-array.h (gfc_get_intrinsic_for_expr,
	gfc_get_proc_ifc_for_expr): New.
	* trans-array.c (gfc_get_intrinsic_for_expr,
	arg_evaluated_for_scalarization): New.
	(gfc_walk_elemental_function_args): Add intrinsic procedure
	as argument.  Count arguments.  Check arg_evaluated_for_scalarization.
	* trans-intrinsic.c (gfc_walk_intrinsic_function): Update call.
	* trans-stmt.c (get_intrinsic_for_code): New.
	(gfc_trans_call): Update call.

gcc/testsuite/ChangeLog:
	* gfortran.dg/index_5.f90: New.
---
 gcc/fortran/trans-array.c             | 61 ++++++++++++++++++++++++++-
 gcc/fortran/trans-array.h             |  3 ++
 gcc/fortran/trans-intrinsic.c         |  1 +
 gcc/fortran/trans-stmt.c              | 20 +++++++++
 gcc/testsuite/gfortran.dg/index_5.f90 | 23 ++++++++++
 5 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/index_5.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-fortran-Ignore-unused-args-in-scalarization-PR97896.patch
Type: text/x-patch
Size: 6975 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211107/f495af6f/attachment-0001.bin>


More information about the Gcc-patches mailing list