NULL_TREE, NULL_TREE);
}
-
static tree
-duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src,
- tree type, int rank)
+duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src, tree type,
+ int rank, tree add_when_allocated)
{
tree tmp;
tree size;
gfc_add_modify (&globalblock, tmp, build_int_cst (TREE_TYPE (tmp), rank));
if (rank)
- nelems = gfc_full_array_size (&block, src, rank);
+ nelems = gfc_full_array_size (&globalblock, src, rank);
else
nelems = integer_one_node;
fold_convert (size_type_node, size));
gfc_add_expr_to_block (&block, tmp);
}
-
+ gfc_add_expr_to_block (&block, add_when_allocated);
tmp = gfc_finish_block (&block);
/* Null the destination if the source is null; otherwise do
gfc_duplicate_allocatable (), where the deep copy code is just added
into the if's body, by adding tmp (the deep copy code) as last
argument to gfc_duplicate_allocatable (). */
- if (purpose == COPY_ALLOC_COMP
+ if (purpose == COPY_ALLOC_COMP && caf_mode == 0
&& GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (dest)))
tmp = gfc_duplicate_allocatable (dest, decl, decl_type, rank,
tmp);
c->caf_token,
NULL_TREE);
}
- tmp = duplicate_allocatable_coarray (dcmp, dst_tok, comp,
- ctype, rank);
+ tmp
+ = duplicate_allocatable_coarray (dcmp, dst_tok, comp, ctype,
+ rank, add_when_allocated);
}
else
tmp = gfc_duplicate_allocatable (dcmp, comp, ctype, rank,
--- /dev/null
+!{ dg-do run }
+
+! Check PR85002 is fixed.
+! Contributed by G. Steinmetz <gscfq@t-online.de>
+
+program pr85002
+ type t
+ integer, allocatable :: a(:)
+ end type
+ type t2
+ type(t), allocatable :: b(:)
+ end type
+ type(t) :: x
+ type(t2) :: y(2)[*]
+
+ allocate (x%a(2))
+ x%a = 123
+ y = t2([x])
+
+ if (.not. all((/(allocated(y(i)%b), i=1, 2)/))) stop 1
+ if (any ((/(y(i)%b(1)%a /= 123, i=1,2)/))) stop 2
+end
+