]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: fix DATA and derived types with pointer components [PR114474]
authorHarald Anlauf <anlauf@gmx.de>
Wed, 27 Mar 2024 20:18:04 +0000 (21:18 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 28 Mar 2024 17:43:47 +0000 (18:43 +0100)
commitbbb7c513dddc5c9b2d5e9b78bc1c2f85a0cfe07e
tree0ea96455d06df5e9598a94b0245d407b53ed8491
parentc1424628dc95829408882f01cbf0dd61566dc312
Fortran: fix DATA and derived types with pointer components [PR114474]

When matching actual arguments in match_actual_arg, these are initially
treated as a possible dummy procedure, assuming that the correct type is
determined later.  This resolution could fail when the procedure is a
derived type constructor with a pointer component and appears in a DATA
statement, where the pointer shall be associated with an initial data
target.  Check for those cases where the type obviously has not been
resolved yet, and which were missed because there was no component
reference.

gcc/fortran/ChangeLog:

PR fortran/114474
* primary.cc (gfc_variable_attr): Catch variables used in structure
constructors within DATA statements that are still tagged with a
temporary type BT_PROCEDURE from match_actual_arg and which have the
target attribute, and fix their typespec.

gcc/testsuite/ChangeLog:

PR fortran/114474
* gfortran.dg/data_pointer_3.f90: New test.
gcc/fortran/primary.cc
gcc/testsuite/gfortran.dg/data_pointer_3.f90 [new file with mode: 0644]