diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2017-01-07 18:26:58 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2017-01-07 18:26:58 +0100 |
commit | de91486c745d5ff6aff491cb9bd1a78875bf090c (patch) | |
tree | f294640f3f31fa5e09df6b9587e7dd3cbfd62c4c /gcc/fortran/trans-intrinsic.c | |
parent | 0fc08a17f0b750eeca8bae85eca0d944e4da130e (diff) | |
download | gcc-de91486c745d5ff6aff491cb9bd1a78875bf090c.zip gcc-de91486c745d5ff6aff491cb9bd1a78875bf090c.tar.gz gcc-de91486c745d5ff6aff491cb9bd1a78875bf090c.tar.bz2 |
re PR fortran/78781 ([Coarray] ICE in gfc_deallocate_scalar_with_status, at fortran/trans.c:1588)
gcc/fortran/ChangeLog:
2017-01-07 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78781
PR fortran/78935
* expr.c (gfc_check_pointer_assign): Return the same error message for
rewritten coarray pointer assignments like for plain ones.
* gfortran.h: Change prototype.
* primary.c (caf_variable_attr): Set attributes used ones only only
ones. Add setting of pointer_comp attribute.
(gfc_caf_attr): Add setting of pointer_comp attribute.
* trans-array.c (gfc_array_allocate): Add flag that the component to
allocate is not an ultimate coarray component. Add allocation of
pointer arrays.
(structure_alloc_comps): Extend nullify to treat pointer components in
coarrays correctly. Restructure nullify to remove redundant code.
(gfc_nullify_alloc_comp): Allow setting caf_mode flags.
* trans-array.h: Change prototype of gfc_nullify_alloc_comp ().
* trans-decl.c (generate_coarray_sym_init): Call nullify_alloc_comp for
derived type coarrays with pointer components.
* trans-expr.c (gfc_trans_structure_assign): Also treat pointer
components.
(trans_caf_token_assign): Handle assignment of token of scalar pointer
components.
(gfc_trans_pointer_assignment): Call above routine.
* trans-intrinsic.c (conv_expr_ref_to_caf_ref): Add treating pointer
components.
(gfc_conv_intrinsic_caf_get): Likewise.
(conv_caf_send): Likewise.
* trans-stmt.c (gfc_trans_allocate): After allocating a derived type in
a coarray pre-register the tokens.
(gfc_trans_deallocate): Simply determining the coarray type (scalar or
array) and deregistering it correctly.
* trans-types.c (gfc_typenode_for_spec): Replace in_coarray flag by the
actual codim to allow lookup of array types in the cache.
(gfc_build_array_type): Likewise.
(gfc_get_array_descriptor_base): Likewise.
(gfc_get_array_type_bounds): Likewise.
(gfc_get_derived_type): Likewise.
* trans-types.h: Likewise.
* trans.c (gfc_deallocate_with_status): Enable deregistering of all kind
of coarray components.
(gfc_deallocate_scalar_with_status): Use free() in fcoarray_single mode
instead of caf_deregister.
libgfortran/ChangeLog:
2017-01-07 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78781
PR fortran/78935
* caf/single.c (send_by_ref): Fix addressing of non-allocatable scalar
destination components.
gcc/testsuite/ChangeLog:
2017-01-07 Andre Vehreschild <vehre@gcc.gnu.org>
* gfortran.dg/coarray/ptr_comp_1.f08: New test.
* gfortran.dg/coarray/ptr_comp_2.f08: New test.
* gfortran.dg/coarray/ptr_comp_3.f08: New test.
* gfortran.dg/coarray/ptr_comp_4.f08: New test.
* gfortran.dg/coarray_ptr_comp_1.f08: New test.
* gfortran.dg/coarray_ptr_comp_2.f08: New test.
* gfortran.dg/coarray_ptr_comp_3.f08: New test.
From-SVN: r244196
Diffstat (limited to 'gcc/fortran/trans-intrinsic.c')
-rw-r--r-- | gcc/fortran/trans-intrinsic.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index a13d3fb..14781ac 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -1123,7 +1123,8 @@ conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) if (expr->symtree) { last_component_ref_tree = expr->symtree->n.sym->backend_decl; - ref_static_array = !expr->symtree->n.sym->attr.allocatable; + ref_static_array = !expr->symtree->n.sym->attr.allocatable + && !expr->symtree->n.sym->attr.pointer; } /* Prevent uninit-warning. */ @@ -1219,7 +1220,8 @@ conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field), inner_struct, field, NULL_TREE); - if (ref->u.c.component->attr.allocatable + if ((ref->u.c.component->attr.allocatable + || ref->u.c.component->attr.pointer) && ref->u.c.component->attr.dimension) { tree arr_desc_token_offset; @@ -1243,7 +1245,8 @@ conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) /* Remember whether this ref was to a non-allocatable/non-pointer component so the next array ref can be tailored correctly. */ - ref_static_array = !ref->u.c.component->attr.allocatable; + ref_static_array = !ref->u.c.component->attr.allocatable + && !ref->u.c.component->attr.pointer; last_component_ref_tree = ref_static_array ? ref->u.c.component->backend_decl : NULL_TREE; break; @@ -1627,7 +1630,7 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind, /* Only use the new get_by_ref () where it is necessary. I.e., when the lhs is reallocatable or the right-hand side has allocatable components. */ - if (caf_attr->alloc_comp || may_realloc) + if (caf_attr->alloc_comp || caf_attr->pointer_comp || may_realloc) { /* Get using caf_get_by_ref. */ caf_reference = conv_expr_ref_to_caf_ref (&se->pre, array_expr); @@ -1876,7 +1879,8 @@ conv_caf_send (gfc_code *code) { lhs_se.expr = gfc_conv_scalar_to_descriptor (&lhs_se, lhs_se.expr, attr); lhs_se.expr = gfc_build_addr_expr (NULL_TREE, lhs_se.expr); } - else if (lhs_caf_attr.alloc_comp && lhs_caf_attr.codimension) + else if ((lhs_caf_attr.alloc_comp || lhs_caf_attr.pointer_comp) + && lhs_caf_attr.codimension) { lhs_se.want_pointer = 1; gfc_conv_expr_descriptor (&lhs_se, lhs_expr); @@ -1930,12 +1934,13 @@ conv_caf_send (gfc_code *code) { temporary and a loop. */ if (!gfc_is_coindexed (lhs_expr) && (!lhs_caf_attr.codimension - || !(lhs_expr->rank > 0 && lhs_caf_attr.allocatable))) + || !(lhs_expr->rank > 0 + && (lhs_caf_attr.allocatable || lhs_caf_attr.pointer)))) { bool lhs_may_realloc = lhs_expr->rank > 0 && lhs_caf_attr.allocatable; gcc_assert (gfc_is_coindexed (rhs_expr)); gfc_init_se (&rhs_se, NULL); - if (lhs_expr->rank == 0 && gfc_expr_attr (lhs_expr).allocatable) + if (lhs_expr->rank == 0 && lhs_caf_attr.allocatable) { gfc_se scal_se; gfc_init_se (&scal_se, NULL); @@ -1997,7 +2002,8 @@ conv_caf_send (gfc_code *code) { rhs_se.expr = gfc_conv_scalar_to_descriptor (&rhs_se, rhs_se.expr, attr); rhs_se.expr = gfc_build_addr_expr (NULL_TREE, rhs_se.expr); } - else if (rhs_caf_attr.alloc_comp && rhs_caf_attr.codimension) + else if ((rhs_caf_attr.alloc_comp || rhs_caf_attr.pointer_comp) + && rhs_caf_attr.codimension) { tree tmp2; rhs_se.want_pointer = 1; @@ -2065,7 +2071,7 @@ conv_caf_send (gfc_code *code) { if (!gfc_is_coindexed (rhs_expr)) { - if (lhs_caf_attr.alloc_comp) + if (lhs_caf_attr.alloc_comp || lhs_caf_attr.pointer_comp) { tree reference, dst_realloc; reference = conv_expr_ref_to_caf_ref (&block, lhs_expr); @@ -2100,7 +2106,7 @@ conv_caf_send (gfc_code *code) { caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl); rhs_image_index = gfc_caf_get_image_index (&block, rhs_expr, caf_decl); tmp = rhs_se.expr; - if (rhs_caf_attr.alloc_comp) + if (rhs_caf_attr.alloc_comp || rhs_caf_attr.pointer_comp) { tmp_stat = gfc_find_stat_co (lhs_expr); |