aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/arith.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/arith.cc')
-rw-r--r--gcc/fortran/arith.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index c4ab75b..c0d12cf 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1342,8 +1342,16 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op,
else
{
gfc_constructor *c = gfc_constructor_first (head);
- r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind,
- &op->where);
+ if (c == NULL)
+ {
+ /* Handle zero-sized arrays. */
+ r = gfc_get_array_expr (op->ts.type, op->ts.kind, &op->where);
+ }
+ else
+ {
+ r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind,
+ &op->where);
+ }
r->shape = gfc_copy_shape (op->shape, op->rank);
r->rank = op->rank;
r->value.constructor = head;
@@ -1501,8 +1509,16 @@ reduce_binary_aa (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **),
else
{
gfc_constructor *c = gfc_constructor_first (head);
- r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind,
- &op1->where);
+ if (c == NULL)
+ {
+ /* Handle zero-sized arrays. */
+ r = gfc_get_array_expr (op1->ts.type, op1->ts.kind, &op1->where);
+ }
+ else
+ {
+ r = gfc_get_array_expr (c->expr->ts.type, c->expr->ts.kind,
+ &op1->where);
+ }
r->shape = gfc_copy_shape (op1->shape, op1->rank);
r->rank = op1->rank;
r->value.constructor = head;