]> 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 13:36:57 +0000 (15:36 +0200)
commita09774a9bbfca578f79e8fae3da4cfc99ddb120b
tree75dbe57358906202c7b9b77ef0cdc1b9bb2e8ab7
parent530380a0af7f620d5c113b963527fe0e3030c058
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.

(cherry picked from commit ec249be3c287c6f1dfb328712ac9c39e6fa95eca)
gcc/fortran/trans-intrinsic.cc
gcc/testsuite/gfortran.dg/pr120191_1.f90 [new file with mode: 0644]