aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-07-26 09:30:37 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-07-26 09:30:37 +0200
commitaf232d48a7e011bf85d12634644ce80c1ad6480d (patch)
tree7605607503ae92b280d32db1d07f72f9865b92a5 /gcc/fortran/trans-expr.c
parent335d2e3964ccd360d718bbad6c9ff616acf8e65a (diff)
downloadgcc-af232d48a7e011bf85d12634644ce80c1ad6480d.zip
gcc-af232d48a7e011bf85d12634644ce80c1ad6480d.tar.gz
gcc-af232d48a7e011bf85d12634644ce80c1ad6480d.tar.bz2
trans-array.c (CAF_TOKEN_FIELD): New macro constant.
2011-07-26 Tobias Burnus <burnus@net-b.de> * trans-array.c (CAF_TOKEN_FIELD): New macro constant. (gfc_conv_descriptor_token): New function. * trans-array.h (gfc_conv_descriptor_token): New prototype. * trans-types.c (gfc_get_array_descriptor_base): For coarrays with -fcoarray=lib, append "void *token" to the array descriptor. (gfc_array_descriptor_base_caf): New static variable. * trans-expr.c (gfc_conv_procedure_call): Handle token and * offset when passing a descriptor coarray to a nondescriptor dummy. 2011-07-26 Tobias Burnus <burnus@net-b.de> * gfortran.dg/coarray_lib_token_2.f90: New. From-SVN: r176784
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 7622910..96510c2 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3395,48 +3395,62 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
if (fsym && fsym->attr.codimension
&& gfc_option.coarray == GFC_FCOARRAY_LIB
&& !fsym->attr.allocatable && fsym->as->type != AS_ASSUMED_SHAPE
- && (e == NULL
- || GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (get_tree_for_caf_expr (e)))))
- /* FIXME: Remove the "||" condition when coarray descriptors have a
- "token" component. This condition occurs when passing an alloc
- coarray or assumed-shape dummy to an explict-shape dummy. */
+ && e == NULL)
{
/* Token and offset. */
VEC_safe_push (tree, gc, stringargs, null_pointer_node);
VEC_safe_push (tree, gc, stringargs,
build_int_cst (gfc_array_index_type, 0));
- gcc_assert (fsym->attr.optional || e != NULL); /* FIXME: "||" cond. */
+ gcc_assert (fsym->attr.optional);
}
else if (fsym && fsym->attr.codimension
&& !fsym->attr.allocatable && fsym->as->type != AS_ASSUMED_SHAPE
&& gfc_option.coarray == GFC_FCOARRAY_LIB)
{
tree caf_decl, caf_type;
- tree offset;
+ tree offset, tmp2;
- caf_decl = get_tree_for_caf_expr (e);
+ caf_decl = get_tree_for_caf_expr (e);
caf_type = TREE_TYPE (caf_decl);
- gcc_assert (GFC_ARRAY_TYPE_P (caf_type)
- && GFC_TYPE_ARRAY_CAF_TOKEN (caf_type) != NULL_TREE);
+ if (GFC_DESCRIPTOR_TYPE_P (caf_type))
+ tmp = gfc_conv_descriptor_token (caf_decl);
+ else
+ {
+ gcc_assert (GFC_ARRAY_TYPE_P (caf_type)
+ && GFC_TYPE_ARRAY_CAF_TOKEN (caf_type) != NULL_TREE);
+ tmp = GFC_TYPE_ARRAY_CAF_TOKEN (caf_type);
+ }
- VEC_safe_push (tree, gc, stringargs,
- GFC_TYPE_ARRAY_CAF_TOKEN (caf_type));
+ VEC_safe_push (tree, gc, stringargs, tmp);
- if (GFC_TYPE_ARRAY_CAF_OFFSET (caf_type) != NULL_TREE)
+ if (GFC_DESCRIPTOR_TYPE_P (caf_type))
+ offset = build_int_cst (gfc_array_index_type, 0);
+ else if (GFC_TYPE_ARRAY_CAF_OFFSET (caf_type) != NULL_TREE)
offset = GFC_TYPE_ARRAY_CAF_OFFSET (caf_type);
else
offset = build_int_cst (gfc_array_index_type, 0);
- gcc_assert (POINTER_TYPE_P (TREE_TYPE (caf_decl))
- && POINTER_TYPE_P (TREE_TYPE (parmse.expr)));
+ if (GFC_DESCRIPTOR_TYPE_P (caf_type))
+ tmp = gfc_conv_descriptor_data_get (caf_decl);
+ else
+ {
+ gcc_assert (POINTER_TYPE_P (caf_type));
+ tmp = caf_decl;
+ }
+
+ if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (parmse.expr)))
+ tmp2 = gfc_conv_descriptor_data_get (parmse.expr);
+ else
+ {
+ gcc_assert (POINTER_TYPE_P (TREE_TYPE (parmse.expr)));
+ tmp2 = parmse.expr;
+ }
tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type,
- fold_convert (gfc_array_index_type,
- parmse.expr),
- fold_convert (gfc_array_index_type,
- caf_decl));
+ fold_convert (gfc_array_index_type, tmp2),
+ fold_convert (gfc_array_index_type, tmp));
offset = fold_build2_loc (input_location, PLUS_EXPR,
gfc_array_index_type, offset, tmp);