Commit fe7a047c by Mikael Morin Committed by Mikael Morin

re PR fortran/35983 (C_LOC in derived type constructor gives weird result)

2008-12-09  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.

2008-12-09  Mikael Morin  <mikael.morin@tele2.fr>

	PR fortran/35983
	* gfortran.dg/pr35983.f90: New test.

From-SVN: r142605
parent b922b5ae
2008-12-09 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.
2008-12-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/38425
......
......@@ -3670,8 +3670,10 @@ gfc_trans_subcomponent_assign (tree dest, gfc_component * cm, gfc_expr * expr)
{
gfc_init_se (&se, NULL);
gfc_conv_expr (&se, expr);
gfc_add_block_to_block (&block, &se.pre);
gfc_add_modify (&block, dest,
fold_convert (TREE_TYPE (dest), se.expr));
gfc_add_block_to_block (&block, &se.post);
}
else
{
......@@ -3713,21 +3715,8 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr)
{
/* Skip absent members in default initializers. */
if (!c->expr)
continue;
continue;
/* Update the type/kind of the expression if it represents either
C_NULL_PTR or C_NULL_FUNPTR. This is done here because this may
be the first place reached for initializing output variables that
have components of type C_PTR/C_FUNPTR that are initialized. */
if (c->expr->ts.type == BT_DERIVED && c->expr->ts.derived
&& c->expr->ts.derived->attr.is_iso_c)
{
c->expr->expr_type = EXPR_NULL;
c->expr->ts.type = c->expr->ts.derived->ts.type;
c->expr->ts.f90_type = c->expr->ts.derived->ts.f90_type;
c->expr->ts.kind = c->expr->ts.derived->ts.kind;
}
field = cm->backend_decl;
tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
dest, field, NULL_TREE);
......
2008-12-09 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35983
* gfortran.dg/pr35983.f90: New test.
2008-12-09 H.J. Lu <hongjiu.lu@intel.com>
PR testsuite/38420
......
! { dg-do run }
!
! PR fortran/35983
! C_LOC expanded to a NULL_PTR expr if called from a structure constructor
!
! Contributed by François-Xavier Coudert
program main
use ISO_C_BINDING
implicit none
type, bind(C) :: descr
type(C_PTR) :: address
end type descr
type(descr) :: DD
double precision, target :: buf(1)
integer (C_INTPTR_T) :: i, j
buf = (/ 0 /)
DD = descr(c_loc(buf))
i = transfer (DD%address, 0_c_intptr_t)
j = transfer (c_loc(buf), 0_c_intptr_t)
if (any((/ i,j /) == 0_c_intptr_t)) call abort
if (i /= j) call abort
end program main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment