aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2020-08-13 16:06:31 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2020-08-13 16:06:31 +0200
commite00464a5cb4214f5a5de4535de4f684a86aa10d5 (patch)
treeb0300f52509913d2d954ece6c56ff9448c92777c /gcc/fortran/trans-array.c
parentdb4615380832d3d3751a70ecdf6fe6c9fe3c4f69 (diff)
downloadgcc-e00464a5cb4214f5a5de4535de4f684a86aa10d5.zip
gcc-e00464a5cb4214f5a5de4535de4f684a86aa10d5.tar.gz
gcc-e00464a5cb4214f5a5de4535de4f684a86aa10d5.tar.bz2
Fix PR fortran/93671; ICE in reffing coarray alloc. comps.
Fix an ICE when in a coarray an allocatable component had another allocatable component. gcc/fortran/ChangeLog: 2020-08-10 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/93671 * trans-array.c (structure_alloc_comps): Keep caf-mode when applying to components; get the caf_token correctly for allocated scalar components. gcc/testsuite/ChangeLog: 2020-08-10 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/93671 * gfortran.dg/coarray/pr93671.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 8f93b43..7a1b2fc 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -8627,14 +8627,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
vref = gfc_build_array_ref (var, index, NULL);
- if ((purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP)
- && !caf_enabled (caf_mode))
+ if (purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP)
{
tmp = build_fold_indirect_ref_loc (input_location,
gfc_conv_array_data (dest));
dref = gfc_build_array_ref (tmp, index, NULL);
tmp = structure_alloc_comps (der_type, vref, dref, rank,
- COPY_ALLOC_COMP, 0, args);
+ COPY_ALLOC_COMP, caf_mode, args);
}
else
tmp = structure_alloc_comps (der_type, vref, NULL_TREE, rank, purpose,
@@ -9375,12 +9374,21 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
else if (flag_coarray == GFC_FCOARRAY_LIB
&& caf_in_coarray (caf_mode))
{
- tree dst_tok = c->as ? gfc_conv_descriptor_token (dcmp)
- : fold_build3_loc (input_location,
- COMPONENT_REF,
- pvoid_type_node, dest,
- c->caf_token,
- NULL_TREE);
+ tree dst_tok;
+ if (c->as)
+ dst_tok = gfc_conv_descriptor_token (dcmp);
+ else
+ {
+ /* For a scalar allocatable component the caf_token is
+ the next component. */
+ if (!c->caf_token)
+ c->caf_token = c->next->backend_decl;
+ dst_tok = fold_build3_loc (input_location,
+ COMPONENT_REF,
+ pvoid_type_node, dest,
+ c->caf_token,
+ NULL_TREE);
+ }
tmp = duplicate_allocatable_coarray (dcmp, dst_tok, comp,
ctype, rank);
}