aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/array.c
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2015-11-14 17:31:16 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2015-11-14 17:31:16 +0000
commit67f0527a22878ddf4be811390d5550d8e9f03d32 (patch)
tree26c1f8082673d754485a608d8d4809767d5aff54 /gcc/fortran/array.c
parent230b4edeee99f2585aefe233f6832cb2d4d68631 (diff)
downloadgcc-67f0527a22878ddf4be811390d5550d8e9f03d32.zip
gcc-67f0527a22878ddf4be811390d5550d8e9f03d32.tar.gz
gcc-67f0527a22878ddf4be811390d5550d8e9f03d32.tar.bz2
re PR fortran/67803 (ICE on concatenating wrong character array constructor)
2015-11-14 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67803 * array.c (gfc_match_array_constructor): If array constructor included a CHARACTER typespec, check array elements for compatible type. 2015-11-14 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/67803 * gfortran.dg/pr67803.f90: New test. From-SVN: r230379
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r--gcc/fortran/array.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index 144d8e0..1e3f0f2 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1162,6 +1162,35 @@ done:
{
expr = gfc_get_array_expr (ts.type, ts.kind, &where);
expr->ts = ts;
+
+ /* If the typespec is CHARACTER, check that array elements can
+ be converted. See PR fortran/67803. */
+ if (ts.type == BT_CHARACTER)
+ {
+ gfc_constructor *c;
+
+ c = gfc_constructor_first (head);
+ for (; c; c = gfc_constructor_next (c))
+ {
+ if (gfc_numeric_ts (&c->expr->ts)
+ || c->expr->ts.type == BT_LOGICAL)
+ {
+ gfc_error ("Incompatible typespec for array element at %L",
+ &c->expr->where);
+ return MATCH_ERROR;
+ }
+
+ /* Special case null(). */
+ if (c->expr->expr_type == EXPR_FUNCTION
+ && c->expr->ts.type == BT_UNKNOWN
+ && strcmp (c->expr->symtree->name, "null") == 0)
+ {
+ gfc_error ("Incompatible typespec for array element at %L",
+ &c->expr->where);
+ return MATCH_ERROR;
+ }
+ }
+ }
}
else
expr = gfc_get_array_expr (BT_UNKNOWN, 0, &where);
@@ -1171,6 +1200,7 @@ done:
expr->ts.u.cl->length_from_typespec = seen_ts;
*result = expr;
+
return MATCH_YES;
syntax: