Commit 03d79dc3 by Janus Weil

re PR fortran/45828 (No default initialization of derived type members?)

2010-09-30  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/45828
	* resolve.c (resolve_allocate_expr): Do not use
	'gfc_has_default_initializer'.

2010-09-30  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/45828
	* gfortran.dg/allocate_derived_5.f90: New.

From-SVN: r164765
parent 78009d9f
2010-09-30 Janus Weil <janus@gcc.gnu.org>
PR fortran/45828
* resolve.c (resolve_allocate_expr): Do not use
'gfc_has_default_initializer'.
2010-09-30 Tobias Burnus <burnus@net-b.de>
* gfortran.tex (Fortran 2008 status): Update list of
......
......@@ -6708,6 +6708,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
{
/* Set up default initializer if needed. */
gfc_typespec ts;
gfc_expr *init_e;
if (code->ext.alloc.ts.type == BT_DERIVED)
ts = code->ext.alloc.ts;
......@@ -6717,9 +6718,8 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
if (ts.type == BT_CLASS)
ts = ts.u.derived->components->ts;
if (ts.type == BT_DERIVED && gfc_has_default_initializer(ts.u.derived))
if (ts.type == BT_DERIVED && (init_e = gfc_default_initializer (&ts)))
{
gfc_expr *init_e = gfc_default_initializer (&ts);
gfc_code *init_st = gfc_get_code ();
init_st->loc = code->loc;
init_st->op = EXEC_INIT_ASSIGN;
......
2010-09-30 Janus Weil <janus@gcc.gnu.org>
PR fortran/45828
* gfortran.dg/allocate_derived_5.f90: New.
2010-09-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/31261
......
! { dg-do run }
!
! PR 45828: [4.6 Regression] No default initialization of derived type members?
!
! Contributed by Juha <jpr@csc.fi>
program fail1
type a
integer :: i
end type a
type b
type(a) :: acomp = a(5)
end type b
type(b), allocatable :: c(:)
allocate(c(1))
if (c(1) % acomp % i /= 5) call abort()
end program fail1
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