]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Fix proc pointer as elemental arg handling
authorTobias Burnus <tobias@codesourcery.com>
Thu, 12 May 2022 08:39:58 +0000 (10:39 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 12 May 2022 08:52:07 +0000 (10:52 +0200)
commitee954d940c41614c75be11b9d1de9079c37044d7
tree946cf65caf1ef861564b523345e05187631621ef
parent492ea356ce4b9e40c417b3740cc298d6cc78e870
Fortran: Fix proc pointer as elemental arg handling

The vtab's _callback function calls the elemental 'cb'
  cb (var(:)%comp, comp_types_vtable._callback);
which gets called in a scalarization loop as 'var' might be a
nonscalar. Without the patch, that got translated as:
  D.1234 = &comp_types_vtable._callback
  ...
   cb (&(*D.4060)[S.3 + D.4071], &D.1234);
where 'D.1234' is function_type. With the patch, it remains a pointer;
i.e. D.1234 = comp... and 'cb (..., D.1234)', avoiding ME ICE.

Note: Fortran (F2018, C15100) requires that dummy arguments are
dummy data objects, which rules out dummy procs/proc-pointer dummies,
which is enforced in resolve_fl_procedure.
Thus, this change only affects the internally generated code.

gcc/fortran/ChangeLog:

        * trans-array.c (gfc_scalar_elemental_arg_saved_as_reference):
Return true for attr.proc_pointer expressions.

gcc/testsuite/ChangeLog:

        * gfortran.dg/finalize_38.f90: Compile with -Ofast.
gcc/fortran/trans-array.c
gcc/testsuite/gfortran.dg/finalize_38.f90