summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-15 13:50:15 +0000
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-15 13:50:15 +0000
commit7bca694e750f2d96e63e6d19aa9c94513592f261 (patch)
tree2d36d040da2849e220509c62394c75c152699789 /gcc/fortran
parent4f95aafeea9a170a795e1074780fc940702e80b4 (diff)
downloadgcc-7bca694e750f2d96e63e6d19aa9c94513592f261.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164305 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c14
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e7f79bdedae..10e4ce21423 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 90d80a7fda0..2d5e04f22d5 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -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)
- {
- code->expr3 = gfc_default_initializer (&ts);
- gfc_resolve_expr (code->expr3);
+ if (ts.type == BT_DERIVED && gfc_has_default_initializer(ts.u.derived))
+ {
+ 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)