This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR fortran/18157 pointer to user-defined type and assignment


The problem here is that we have a(1:2)%field = a(2:3)%field and we need a
temparory array to store the result of a(2:3)%field so that a(2)%field does
not get overwritten but we were using the wrong type.  We used the type of
a(2) and not of a(2)%field.  This patch fixes the problem by using the
type of the field rather than the type of the defined type.

OK? Bootstrapped and tested on x86_64-pc-linux-gnu with no regressions.

Also note I created three different testcases.  The first two really should
not need an temporary array but current uses one (someone else needs to look
into that).  The last one is the only one which really needs one.

Thanks,
Andrew Pinski

ChangeLog:
	* trans-array.c (gfc_conv_resolve_dependencies): Use the correct
	type of the temparory array.
	* trans-expr.c (gfc_trans_assignment): Pass lss instead of lss_section
	to gfc_conv_resolve_dependencies to get the correct type.

testsuite/ChangeLog:
	* gfortran.fortran-torture/compile/defined_type_1.f90: New test.
	* gfortran.fortran-torture/compile/defined_type_2.f90: New test.
	* gfortran.fortran-torture/compile/defined_type_3.f90: New test.

Attachment: fixt.diff.txt
Description: ASCII C program text


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]