https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97896
--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Mikael Morin <mik...@gcc.gnu.org>: https://gcc.gnu.org/g:e63ef9ae51ab67fdd280401e643eb97fddef8d93 commit r11-9467-ge63ef9ae51ab67fdd280401e643eb97fddef8d93 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Sun Jan 16 16:26:15 2022 +0100 Fortran: Fix KIND argument index for LEN_TRIM. The mainline code to check whether an argument has to be included in scalarization uses only the name of a dummy argument object to recognize a specific argument of an intrinsic procedure. On the 11 branch, the dummy argument object is not available and the code uses a mix of check for argument name (for keyword arguments) and argument index (for non-keyword ones). This makes backports non-straightforward in this area, as the argument indexes depend on the intrinsics. This change fixes a bogus backport for LEN_TRIM, whose KIND argument index should be different from that of INDEX. PR fortran/87711 PR fortran/97896 gcc/fortran/ChangeLog: * trans-array.c (arg_evaluated_for_scalarization): Handle keyword and non-keyword arguments separatedly. Adapt the expected argument index for KIND to each intrinsic in the non-keyword case. gcc/testsuite/ChangeLog: * gfortran.dg/index_5.f90: Enrich test with usages of INDEX with a non-keyword KIND argument. * gfortran.dg/len_trim.f90: Same for LEN_TRIM. (tests cherry picked from commit 15630e6e9eb019477d1fc5c0966b43979e18ae18)