2013-07-22 Tobias Burnus <burnus@net-b.de>
PR fortran/57906
PR fortran/52052
* class.c (gfc_build_class_symbol): Set coarray_comp.
* trans-array.c (structure_alloc_comps): For coarrays,
directly use the data pointer address.
2013-07-22 Tobias Burnus <burnus@net-b.de>
PR fortran/57906
PR fortran/52052
* coarray/lib_realloc_1.f90: Permit optimization.
* gfortran.dg/coarray_31.f90: New.
@@ -666,6 +666,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
fclass->attr.extension = ts->u.derived->attr.extension + 1;
fclass->attr.alloc_comp = ts->u.derived->attr.alloc_comp;
+ fclass->attr.coarray_comp = ts->u.derived->attr.coarray_comp;
}
fclass->attr.is_class = 1;
@@ -7589,9 +7589,9 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
if ((c->ts.type == BT_DERIVED && !c->attr.pointer)
|| (c->ts.type == BT_CLASS && !CLASS_DATA (c)->attr.class_pointer))
- {
- comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
- decl, cdecl, NULL_TREE);
+ {
+ comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
/* The finalizer frees allocatable components. */
called_dealloc_with_status
@@ -7737,8 +7737,17 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
cdecl, NULL_TREE);
dcmp = fold_build3_loc (input_location, COMPONENT_REF, ctype, dest,
cdecl, NULL_TREE);
+
if (c->attr.codimension)
- gfc_add_modify (&fnblock, dcmp, comp);
+ {
+ if (c->ts.type == BT_CLASS)
+ {
+ comp = gfc_class_data_get (comp);
+ dcmp = gfc_class_data_get (dcmp);
+ }
+ gfc_conv_descriptor_data_set (&fnblock, dcmp,
+ gfc_conv_descriptor_data_get (comp));
+ }
else
{
tmp = structure_alloc_comps (c->ts.u.derived, comp, dcmp,
@@ -1,5 +1,4 @@
! { dg-do run }
-! { dg-options "-O0" }
!
! Test that for CAF components _gfortran_caf_deregister is called
! Test that norealloc happens for CAF components during assignment
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original -fcoarray=single" }
+!
+! PR fortran/57906
+! PR fortran/52052
+!
+type t
+ integer, allocatable :: x(:)[:]
+ class(*), allocatable :: z(:)[:]
+ class(*), allocatable :: d[:]
+end type t
+type t2
+ type(t) :: y
+end type t2
+type(t2) :: a, b
+a = b
+end
+
+! { dg-final { scan-tree-dump "a.y.x.data = D.\[0-9\]+.y.x.data;" "original" } }
+! { dg-final { scan-tree-dump "a.y.z._data.data = D.\[0-9\]+.y.z._data.data;" "original" } }
+! { dg-final { scan-tree-dump "a.y.d._data.data = D.\[0-9\]+.y.d._data.data;" "original" } }
+! { dg-final { cleanup-tree-dump "original" } }