From 26f391e8067e96e4fba7b531eda9fb80023f2fd2 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Fri, 30 Sep 2016 12:20:59 +0200 Subject: trans-array.c (gfc_array_allocate): Use the token from coarray's .token member. gcc/fortran/ChangeLog: 2016-09-30 Andre Vehreschild * trans-array.c (gfc_array_allocate): Use the token from coarray's .token member. * trans-intrinsic.c (conv_expr_ref_to_caf_ref): Only generate caf-reference chains from the first coarray references on. * trans-types.c (gfc_get_derived_type): Switch on mandatory .token member generation for allocatable arrays in coarrays in derived types. gcc/testsuite/ChangeLog: 2016-09-30 Andre Vehreschild * gfortran.dg/coarray_allocate_10.f08: New test. * gfortran.dg/coindexed_1.f90: Above fixes allow execution. From-SVN: r240650 --- gcc/fortran/trans-intrinsic.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'gcc/fortran/trans-intrinsic.c') diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 954f7b3..a499c32 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -1110,7 +1110,7 @@ compute_component_offset (tree field, tree type) static tree conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) { - gfc_ref *ref = expr->ref; + gfc_ref *ref = expr->ref, *last_comp_ref; tree caf_ref = NULL_TREE, prev_caf_ref = NULL_TREE, reference_type, tmp, tmp2, field, last_type, inner_struct, mode, mode_rhs, dim_array, dim, dim_type, start, end, stride, vector, nvec; @@ -1127,8 +1127,29 @@ conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) /* Prevent uninit-warning. */ reference_type = NULL_TREE; - last_type = gfc_typenode_for_spec (&expr->symtree->n.sym->ts); - last_type_n = expr->symtree->n.sym->ts.type; + + /* Skip refs upto the first coarray-ref. */ + last_comp_ref = NULL; + while (ref && (ref->type != REF_ARRAY || ref->u.ar.codimen == 0)) + { + /* Remember the type of components skipped. */ + if (ref->type == REF_COMPONENT) + last_comp_ref = ref; + ref = ref->next; + } + /* When a component was skipped, get the type information of the last + component ref, else get the type from the symbol. */ + if (last_comp_ref) + { + last_type = gfc_typenode_for_spec (&last_comp_ref->u.c.component->ts); + last_type_n = last_comp_ref->u.c.component->ts.type; + } + else + { + last_type = gfc_typenode_for_spec (&expr->symtree->n.sym->ts); + last_type_n = expr->symtree->n.sym->ts.type; + } + while (ref) { if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0 -- cgit v1.1