This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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, Fortran] PR 35983 C_LOC expanded to a NULL_PTR expr if called from a structure constructor


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.

Attachment: pr35983_17.diff
Description: Text document


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