]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Fix up minloc/maxloc lowering [PR120191]
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 May 2025 12:14:55 +0000 (14:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 May 2025 12:14:55 +0000 (14:14 +0200)
commitec249be3c287c6f1dfb328712ac9c39e6fa95eca
treecb22cc6c4bd82ed24266f4b0425e36e0105c58a2
parent940bc09b446f4876563b0986231724121b33193d
fortran: Fix up minloc/maxloc lowering [PR120191]

We need to drop the kind argument from what is passed to the
library, but need to do it not only when one uses the argument name
for it (so kind=4 etc.) but also when one passes all the arguments
to the intrinsics.

The following patch uses what gfc_conv_intrinsic_findloc uses,
which looks more efficient and cleaner, we already set automatic
vars to point to the kind and back actual arguments, so we can just
free/clear expr on the former and set name to "%VAL" on the latter.

And similarly clears dim argument for the BT_CHARACTER case when using
maxloc2/minloc2, again regardless of whether it was named or not.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>
    Daniil Kochergin  <daniil2472s@gmail.com>
    Tobias Burnus  <tburnus@baylibre.com>

PR fortran/120191
* trans-intrinsic.cc (strip_kind_from_actual): Remove.
(gfc_conv_intrinsic_minmaxloc): Don't call strip_kind_from_actual.
Free and clear kind_arg->expr if non-NULL.  Set back_arg->name to
"%VAL" instead of a loop looking for last argument.  Remove actual
variable, use array_arg instead.  Free and clear dim_arg->expr if
non-NULL for BT_CHARACTER cases instead of using a loop.

* gfortran.dg/pr120191_1.f90: New test.
gcc/fortran/trans-intrinsic.cc
gcc/testsuite/gfortran.dg/pr120191_1.f90 [new file with mode: 0644]