fortran: Set name for *LOC default BACK argument [PR108450]
authorMikael Morin <mikael@gcc.gnu.org>
Sun, 29 Jan 2023 20:57:24 +0000 (21:57 +0100)
committerMikael Morin <mikael@gcc.gnu.org>
Sun, 29 Jan 2023 20:57:24 +0000 (21:57 +0100)
commit2e32a12c04c72f692a7bd119fd3e4e5b74392c9d
tree1c16182b3e9ed87673abdf1faf8cf9113a2d90dd
parent8011fbba7baa46947341ca8069b5a327163a68d5
fortran: Set name for *LOC default BACK argument [PR108450]

This change fixes an ICE caused by the double resolution of MINLOC,
MAXLOC and FINDLOC expressions which get a default value for the BACK
argument at resolution time.  That argument  is added without name,
and argument reordering code is not prepared to handle unnamed arguments
coming after named ones, so the second resolution causes a NULL pointer
dereference.
The problem is fixed by explicitly setting the argument name.

PR fortran/108450

gcc/fortran/ChangeLog:

* check.cc (gfc_check_minloc_maxloc): Explicitly set argument name.
(gfc_check_findloc): Ditto.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/minmaxloc_1.f90: New test.
gcc/fortran/check.cc
gcc/testsuite/gfortran.dg/gomp/minmaxloc_1.f90 [new file with mode: 0644]