From e75eb64fdf7296fa333f49f0186f1e219fed16ad Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Sat, 14 May 2016 15:29:13 +0000 Subject: re PR fortran/71047 (Allocatable component of INTENT(OUT) dummy not set correctly) 2016-05-14 Fritz Reese PR fortran/71047 * expr.c (gfc_default_initializer): Avoid extra component refs in constructors for derived types and classes. 2016-05-14 Fritz Reese PR fortran/71047 * gfortran.dg/pr71047.f08: New test. From-SVN: r236241 --- gcc/fortran/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/expr.c') diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 6ebe08b..d1258cd 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3975,7 +3975,10 @@ gfc_default_initializer (gfc_typespec *ts) if (comp->initializer) { - ctor->n.component = comp; + /* Save the component ref for STRUCTUREs and UNIONs. */ + if (ts->u.derived->attr.flavor == FL_STRUCT + || ts->u.derived->attr.flavor == FL_UNION) + ctor->n.component = comp; ctor->expr = gfc_copy_expr (comp->initializer); if ((comp->ts.type != comp->initializer->ts.type || comp->ts.kind != comp->initializer->ts.kind) -- cgit v1.1