aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-07-21 14:00:25 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-07-21 14:00:25 +0200
commit0c53708eadd727f4089028e09840865db25a3cd9 (patch)
tree90e38bf99a56bacbccf1b030246599e15eccdf02 /gcc/fortran/trans-decl.c
parent91bc61122f0f6781805aab89e21f674b218c72c9 (diff)
downloadgcc-0c53708eadd727f4089028e09840865db25a3cd9.zip
gcc-0c53708eadd727f4089028e09840865db25a3cd9.tar.gz
gcc-0c53708eadd727f4089028e09840865db25a3cd9.tar.bz2
check.c (gfc_check_present): Allow coarrays.
2011-07-21 Tobias Burnus <burnus@net-b.de> * check.c (gfc_check_present): Allow coarrays. * trans-array.c (gfc_conv_array_ref): Avoid casting when a pointer is wanted. * trans-decl.c (create_function_arglist): For -fcoarray=lib, handle hidden token and offset arguments for nondescriptor coarrays. * trans-expr.c (get_tree_for_caf_expr): New function. (gfc_conv_procedure_call): For -fcoarray=lib pass the token and offset for nondescriptor coarray dummies. * trans.h (lang_type): Add caf_offset tree. (GFC_TYPE_ARRAY_CAF_OFFSET): New macro. 2011-07-21 Tobias Burnus <burnus@net-b.de> * gfortran.dg/coarray_lib_token_1.f90: New. From-SVN: r176562
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 65a8efa..12c5262 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -2104,6 +2104,48 @@ create_function_arglist (gfc_symbol * sym)
f->sym->backend_decl = parm;
+ /* Coarrays which do not use a descriptor pass with -fcoarray=lib the
+ token and the offset as hidden arguments. */
+ if (f->sym->attr.codimension
+ && gfc_option.coarray == GFC_FCOARRAY_LIB
+ && !f->sym->attr.allocatable
+ && f->sym->as->type != AS_ASSUMED_SHAPE)
+ {
+ tree caf_type;
+ tree token;
+ tree offset;
+
+ gcc_assert (f->sym->backend_decl != NULL_TREE
+ && !sym->attr.is_bind_c);
+ caf_type = TREE_TYPE (f->sym->backend_decl);
+
+ gcc_assert (GFC_TYPE_ARRAY_CAF_TOKEN (caf_type) == NULL_TREE);
+ token = build_decl (input_location, PARM_DECL,
+ create_tmp_var_name ("caf_token"),
+ build_qualified_type (pvoid_type_node,
+ TYPE_QUAL_RESTRICT));
+ GFC_TYPE_ARRAY_CAF_TOKEN (caf_type) = token;
+ DECL_CONTEXT (token) = fndecl;
+ DECL_ARTIFICIAL (token) = 1;
+ DECL_ARG_TYPE (token) = TREE_VALUE (typelist);
+ TREE_READONLY (token) = 1;
+ hidden_arglist = chainon (hidden_arglist, token);
+ gfc_finish_decl (token);
+
+ gcc_assert (GFC_TYPE_ARRAY_CAF_OFFSET (caf_type) == NULL_TREE);
+ offset = build_decl (input_location, PARM_DECL,
+ create_tmp_var_name ("caf_offset"),
+ gfc_array_index_type);
+
+ GFC_TYPE_ARRAY_CAF_OFFSET (caf_type) = offset;
+ DECL_CONTEXT (offset) = fndecl;
+ DECL_ARTIFICIAL (offset) = 1;
+ DECL_ARG_TYPE (offset) = TREE_VALUE (typelist);
+ TREE_READONLY (offset) = 1;
+ hidden_arglist = chainon (hidden_arglist, offset);
+ gfc_finish_decl (offset);
+ }
+
arglist = chainon (arglist, parm);
typelist = TREE_CHAIN (typelist);
}