aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/array.c
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2019-09-02 16:46:54 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2019-09-02 16:46:54 +0000
commitbe0fb5484a64414878c31a1606b07175b54ecb90 (patch)
tree9a1396879160a26623228b2dae36b7b8fe54b292 /gcc/fortran/array.c
parentb82c2e6fce74a6283fb3efd195d62aa6a88ef561 (diff)
downloadgcc-be0fb5484a64414878c31a1606b07175b54ecb90.zip
gcc-be0fb5484a64414878c31a1606b07175b54ecb90.tar.gz
gcc-be0fb5484a64414878c31a1606b07175b54ecb90.tar.bz2
re PR fortran/91552 (ICE with valid array constructor)
2019-09-02 Steven G. Kargl <kargl@gc.gnu.org> PR fortran/91552 * array.c (walk_array_constructor): New function. (gfc_match_array_constructor): Use it. 2019-09-02 Steven G. Kargl <kargl@gc.gnu.org> PR fortran/91552 * gfortran.dg/pr91552.f90: New test. From-SVN: r275322
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r--gcc/fortran/array.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index b972abe..ba8a816 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1134,6 +1134,31 @@ done:
}
+/* Convert components of an array constructor to the type in ts. */
+
+static match
+walk_array_constructor (gfc_typespec *ts, gfc_constructor_base head)
+{
+ gfc_constructor *c;
+ gfc_expr *e;
+ match m;
+
+ for (c = gfc_constructor_first (head); c; c = gfc_constructor_next (c))
+ {
+ e = c->expr;
+ if (e->expr_type == EXPR_ARRAY && e->ts.type == BT_UNKNOWN
+ && !e->ref && e->value.constructor)
+ {
+ m = walk_array_constructor (ts, e->value.constructor);
+ if (m == MATCH_ERROR)
+ return m;
+ }
+ else if (!gfc_convert_type (e, ts, 1) && e->ts.type != BT_UNKNOWN)
+ return MATCH_ERROR;
+ }
+ return MATCH_YES;
+}
+
/* Match an array constructor. */
match
@@ -1263,14 +1288,13 @@ done:
}
}
- /* Walk the constructor and ensure type conversion for numeric types. */
+ /* Walk the constructor, and if possible, do type conversion for
+ numeric types. */
if (gfc_numeric_ts (&ts))
{
- c = gfc_constructor_first (head);
- for (; c; c = gfc_constructor_next (c))
- if (!gfc_convert_type (c->expr, &ts, 1)
- && c->expr->ts.type != BT_UNKNOWN)
- return MATCH_ERROR;
+ m = walk_array_constructor (&ts, head);
+ if (m == MATCH_ERROR)
+ return m;
}
}
else