https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107635
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Andre Vehreschild <ve...@gcc.gnu.org>: https://gcc.gnu.org/g:91d52f87c5bc48eacaf305d515e7cce192c2cf9c commit r15-6414-g91d52f87c5bc48eacaf305d515e7cce192c2cf9c Author: Andre Vehreschild <ve...@gcc.gnu.org> Date: Thu Oct 31 15:35:47 2024 +0100 Fortran: Remove adding and removing of caf_get. [PR107635] Preparatory work for PR107635. During resolve prevent adding caf_get calls for expressions on the left-hand-side of an assignment and removing them later on again. Furthermore has the caf_token in a component become a pointer to the component and not the backend_decl of the caf-component. In some cases the caf_token was added as last component in a derived type and not as the next one following the component that it was needed to be associated to. gcc/fortran/ChangeLog: PR fortran/107635 * gfortran.h (gfc_comp_caf_token): Convenient macro for accessing caf_token's tree. * resolve.cc (gfc_resolve_ref): Backup caf_lhs when resolving expr in array_ref. (remove_caf_get_intrinsic): Removed. (resolve_variable): Set flag caf_lhs when resolving lhs of assignment to prevent insertion of caf_get. (resolve_lock_unlock_event): Same, but the lhs is the parameter. (resolve_ordinary_assign): Move conversion to caf_send to resolve_codes. (resolve_codes): Adress caf_get and caf_send here. (resolve_fl_derived0): Set component's caf_token when token is necessary. * trans-array.cc (gfc_conv_array_parameter): Get a coarray for expression that have a corank. (structure_alloc_comps): Use macro to get caf_token's tree. (gfc_alloc_allocatable_for_assignment): Same. * trans-expr.cc (gfc_get_ultimate_alloc_ptr_comps_caf_token): Same. (gfc_trans_structure_assign): Same. * trans-intrinsic.cc (conv_expr_ref_to_caf_ref): Same. (has_ref_after_cafref): New function to figure that after a reference of a coarray another reference is present. (conv_caf_send): Get rhs from correct place, when caf_get is not removed. * trans-types.cc (gfc_get_derived_type): Get caf_token from component and no longer guessing.