re PR fortran/45577 (Bogus(?) "... type incompatible with source-expr ..." error)

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

	PR fortran/45577
	* resolve.c (resolve_allocate_expr): Do default initialization via
	EXEC_INIT_ASSIGN.


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

	PR fortran/45577
	* gfortran.dg/allocate_derived_4.f90: New.

From-SVN: r164305
This commit is contained in:
Janus Weil 2010-09-15 15:50:15 +02:00
parent ea395a11a3
commit edd2b56ab9
4 changed files with 39 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2010-09-15 Janus Weil <janus@gcc.gnu.org>
PR fortran/45577
* resolve.c (resolve_allocate_expr): Do default initialization via
EXEC_INIT_ASSIGN.
2010-09-11 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* mathbuiltins.def: Do not defined huge_val built-in.

View File

@ -6697,10 +6697,16 @@ 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)
if (ts.type == BT_DERIVED && gfc_has_default_initializer(ts.u.derived))
{
code->expr3 = gfc_default_initializer (&ts);
gfc_resolve_expr (code->expr3);
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;
init_st->expr1 = gfc_expr_to_initialize (e);
init_st->expr2 = init_e;
init_st->next = code->next;
code->next = init_st;
}
}
else if (code->expr3->mold && code->expr3->ts.type == BT_DERIVED)

View File

@ -1,3 +1,8 @@
2010-09-15 Janus Weil <janus@gcc.gnu.org>
PR fortran/45577
* gfortran.dg/allocate_derived_4.f90: New.
2010-09-15 Tejas Belagod <tejas.belagod@arm.com>
* lib/target-supports.exp

View File

@ -0,0 +1,19 @@
! { dg-do compile }
!
! PR 45577: [4.6 Regression] Bogus(?) "... type incompatible with source-expr ..." error
!
! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
program main
type b_obj
integer,allocatable :: c(:)
real :: r = 5.
end type b_obj
type (b_obj),allocatable :: b(:)
integer,allocatable :: c(:)
allocate(b(3),c(3))
end program main