aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-05-31 20:25:51 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-05-31 20:25:51 +0200
commit9f3761c527c003969c4f18497876c4d18b5f2305 (patch)
tree59427254682f41e38c3837a5da77e001222c18ee /gcc/fortran/trans-array.c
parent4ed2ca85c2b04527c59ec3e4bc7d88770c60dee2 (diff)
downloadgcc-9f3761c527c003969c4f18497876c4d18b5f2305.zip
gcc-9f3761c527c003969c4f18497876c4d18b5f2305.tar.gz
gcc-9f3761c527c003969c4f18497876c4d18b5f2305.tar.bz2
re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
2011-05-31 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * resolve.c (resolve_fl_variable): Handle static coarrays with non-constant cobounds. (resolve_symbol): Handle SAVE statement without arguments for coarrays. * trans-array.c (gfc_trans_array_cobounds): New function. (gfc_trans_array_bounds): Place code by call to it. * trans-array.h (gfc_trans_array_cobounds): New prototype. * trans-decl.c (gfc_get_symbol_decl, gfc_trans_deferred_vars): Handle static coarrays with nonconstant cobounds. 2011-05-31 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * gfortran.dg/coarray/save_1.f90: New. * gfortran.dg/coarray_4.f90: Update dg-error. From-SVN: r174503
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c59
1 files changed, 39 insertions, 20 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index d83a7a9..0c6c638 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -4648,6 +4648,43 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
}
+/* Generate code to evaluate non-constant coarray cobounds. */
+
+void
+gfc_trans_array_cobounds (tree type, stmtblock_t * pblock,
+ const gfc_symbol *sym)
+{
+ int dim;
+ tree ubound;
+ tree lbound;
+ gfc_se se;
+ gfc_array_spec *as;
+
+ as = sym->as;
+
+ for (dim = as->rank; dim < as->rank + as->corank; dim++)
+ {
+ /* Evaluate non-constant array bound expressions. */
+ lbound = GFC_TYPE_ARRAY_LBOUND (type, dim);
+ if (as->lower[dim] && !INTEGER_CST_P (lbound))
+ {
+ gfc_init_se (&se, NULL);
+ gfc_conv_expr_type (&se, as->lower[dim], gfc_array_index_type);
+ gfc_add_block_to_block (pblock, &se.pre);
+ gfc_add_modify (pblock, lbound, se.expr);
+ }
+ ubound = GFC_TYPE_ARRAY_UBOUND (type, dim);
+ if (as->upper[dim] && !INTEGER_CST_P (ubound))
+ {
+ gfc_init_se (&se, NULL);
+ gfc_conv_expr_type (&se, as->upper[dim], gfc_array_index_type);
+ gfc_add_block_to_block (pblock, &se.pre);
+ gfc_add_modify (pblock, ubound, se.expr);
+ }
+ }
+}
+
+
/* Generate code to evaluate non-constant array bounds. Sets *poffset and
returns the size (in elements) of the array. */
@@ -4728,26 +4765,8 @@ gfc_trans_array_bounds (tree type, gfc_symbol * sym, tree * poffset,
size = stride;
}
- for (dim = as->rank; dim < as->rank + as->corank; dim++)
- {
- /* Evaluate non-constant array bound expressions. */
- lbound = GFC_TYPE_ARRAY_LBOUND (type, dim);
- if (as->lower[dim] && !INTEGER_CST_P (lbound))
- {
- gfc_init_se (&se, NULL);
- gfc_conv_expr_type (&se, as->lower[dim], gfc_array_index_type);
- gfc_add_block_to_block (pblock, &se.pre);
- gfc_add_modify (pblock, lbound, se.expr);
- }
- ubound = GFC_TYPE_ARRAY_UBOUND (type, dim);
- if (as->upper[dim] && !INTEGER_CST_P (ubound))
- {
- gfc_init_se (&se, NULL);
- gfc_conv_expr_type (&se, as->upper[dim], gfc_array_index_type);
- gfc_add_block_to_block (pblock, &se.pre);
- gfc_add_modify (pblock, ubound, se.expr);
- }
- }
+
+ gfc_trans_array_cobounds (type, pblock, sym);
gfc_trans_vla_type_sizes (sym, pblock);
*poffset = offset;