aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/simplify.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-12-15 15:53:55 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2011-12-15 15:53:55 +0100
commit492792ed9b7a3b6ce5f595b2dc848eb2dae8116f (patch)
tree64b1cf86d7267525f4882d22ee8dde0a6c359b88 /gcc/fortran/simplify.c
parent9d69847d6ea68145f1b065d5d4a1cafadebf0d37 (diff)
downloadgcc-492792ed9b7a3b6ce5f595b2dc848eb2dae8116f.zip
gcc-492792ed9b7a3b6ce5f595b2dc848eb2dae8116f.tar.gz
gcc-492792ed9b7a3b6ce5f595b2dc848eb2dae8116f.tar.bz2
primary.c (gfc_match_varspec): Match array spec for polymorphic coarrays.
2011-12-15 Tobias Burnus <burnus@net-b.de> * primary.c (gfc_match_varspec): Match array spec for polymorphic coarrays. (gfc_match_rvalue): If a symbol of unknown flavor has a codimension, mark it as a variable. * simplify.c (gfc_simplify_image_index): Directly call simplify_cobound. * trans-intrinsic.c (trans_this_image): Fix handling of corank = 1 arrays. 2011-12-15 Tobias Burnus <burnus@net-b.de> * gfortran.dg/coarray/poly_run_3.f90: New. * gfortran.dg/coarray/poly_run_2.f90: Enable comment-out test. From-SVN: r182371
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r--gcc/fortran/simplify.c74
1 files changed, 2 insertions, 72 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index e82753a..282d88d 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -6227,10 +6227,6 @@ gfc_simplify_image_index (gfc_expr *coarray, gfc_expr *sub)
gfc_expr *
gfc_simplify_this_image (gfc_expr *coarray, gfc_expr *dim)
{
- gfc_ref *ref;
- gfc_array_spec *as;
- int d;
-
if (gfc_option.coarray != GFC_FCOARRAY_SINGLE)
return NULL;
@@ -6244,74 +6240,8 @@ gfc_simplify_this_image (gfc_expr *coarray, gfc_expr *dim)
return result;
}
- gcc_assert (coarray->expr_type == EXPR_VARIABLE);
-
- /* Follow any component references. */
- as = coarray->symtree->n.sym->as;
- for (ref = coarray->ref; ref; ref = ref->next)
- if (ref->type == REF_COMPONENT)
- as = ref->u.ar.as;
-
- if (as->type == AS_DEFERRED)
- return NULL;
-
- if (dim == NULL)
- {
- /* Multi-dimensional bounds. */
- gfc_expr *bounds[GFC_MAX_DIMENSIONS];
- gfc_expr *e;
-
- /* Simplify the bounds for each dimension. */
- for (d = 0; d < as->corank; d++)
- {
- bounds[d] = simplify_bound_dim (coarray, NULL, d + as->rank + 1, 0,
- as, NULL, true);
- if (bounds[d] == NULL || bounds[d] == &gfc_bad_expr)
- {
- int j;
-
- for (j = 0; j < d; j++)
- gfc_free_expr (bounds[j]);
-
- return bounds[d];
- }
- }
-
- /* Allocate the result expression. */
- e = gfc_get_expr ();
- e->where = coarray->where;
- e->expr_type = EXPR_ARRAY;
- e->ts.type = BT_INTEGER;
- e->ts.kind = gfc_default_integer_kind;
-
- e->rank = 1;
- e->shape = gfc_get_shape (1);
- mpz_init_set_ui (e->shape[0], as->corank);
-
- /* Create the constructor for this array. */
- for (d = 0; d < as->corank; d++)
- gfc_constructor_append_expr (&e->value.constructor,
- bounds[d], &e->where);
-
- return e;
- }
- else
- {
- /* A DIM argument is specified. */
- if (dim->expr_type != EXPR_CONSTANT)
- return NULL;
-
- d = mpz_get_si (dim->value.integer);
-
- if (d < 1 || d > as->corank)
- {
- gfc_error ("DIM argument at %L is out of bounds", &dim->where);
- return &gfc_bad_expr;
- }
-
- return simplify_bound_dim (coarray, NULL, d + as->rank, 0, as, NULL,
- true);
- }
+ /* For -fcoarray=single, this_image(A) is the same as lcobound(A). */
+ return simplify_cobound (coarray, dim, NULL, 0);
}