[Patch, Fortran] PR 35983 C_LOC expanded to a NULL_PTR expr if called from a structure constructor
Mikael Morin
mikael.morin@tele2.fr
Mon Dec 8 14:15:00 GMT 2008
Hello all,
gfortran-4.4 is not dead (yet).
This patch solves code like this:
type, bind(C) :: descr
type(C_PTR) :: address
end type descr
type(descr) :: DD
double precision, target :: buf(1)
DD = descr(c_loc(buf))
where C_LOC's value was unconditionally reset to NULL_PTR.
The patch simply removes the C_NULL_(FUN)PTR specific code in
gfc_trans_structure_assign as it is redundant with that of gfc_conv_expr.
The next problem was that DD%address was left uninitialized.
I found out that in gfc_trans_subcomponent_assign, we were using
se.expr, but we were dropping se.pre and se.post.
Adding them to the current block solves the problem.
Regression-tested on x86_64-unknown-linux-gnu.
Ok for 4.4 (and 4.3?) ?
Mikael
2008-12-08 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35983
* gfortran.dg/pr35983.f90: New test.
2008-12-08 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35983
* trans-expr.c (gfc_trans_subcomponent_assign):
Add se's pre and post blocks to current block.
(gfc_trans_structure_assign): Remove specific handling
of C_NULL_PTR and C_NULL_FUNPTR.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr35983_17.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20081208/ce138a7f/attachment.ksh>
More information about the Fortran
mailing list