Correct decls for functions which do not pass actual arguments.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 25 Oct 2020 12:16:16 +0000 (13:16 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 25 Oct 2020 12:17:06 +0000 (13:17 +0100)
commit47d13acbda9a5d8eb57ff169ba74857cd54108e4
tree9f8172cd70724fd0abd232cfc3679e8448a8db7b
parentd7ddd287ca76e87f431f43687de6d8cc48e52543
Correct decls for functions which do not pass actual arguments.

A wrong decl for findloc caused segfaults at runtime on
Darwin for ARM; however, this is only a symptom of a larger
disease: The declarations for our library functions are often
inconsistent.  This patch solves that problem for the functions
specifically for the functions for which we do not pass optional
arguments, i.e. findloc and (min|max)loc.

It works by saving the symbols of the specific functions in
gfc_intrinsic_namespace and by generating the formal argument
lists from the actual argument lists.  Because symbols are
re-used, so are the backend decls.

gcc/fortran/ChangeLog:

PR fortran/97454
* gfortran.h (gfc_symbol): Add pass_as_value flag.
(gfc_copy_formal_args_intr): Add optional argument
copy_type.
(gfc_get_intrinsic_function_symbol): Add prototype.
(gfc_find_intrinsic_symbol): Add prototype.
* intrinsic.c (gfc_get_intrinsic_function_symbol): New function.
(gfc_find_intrinsic_symbol): New function.
* symbol.c (gfc_copy_formal_args_intr): Add argument. Handle case
where the type needs to be copied from the actual argument.
* trans-intrinsic.c (remove_empty_actual_arguments): New function.
(specific_intrinsic_symbol): New function.
(gfc_conv_intrinsic_funcall): Use it.
(strip_kind_from_actual): Adjust so that the expression pointer
is set to NULL.
(gfc_conv_intrinsic_minmaxloc): Likewise.
(gfc_conv_intrinsic_minmaxval): Adjust removal of dim.
* trans-types.c (gfc_sym_type): If sym->pass_as_value is set, do
not pass by reference.
gcc/fortran/gfortran.h
gcc/fortran/intrinsic.c
gcc/fortran/symbol.c
gcc/fortran/trans-intrinsic.c
gcc/fortran/trans-types.c