aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/resolve.cc13
-rw-r--r--gcc/testsuite/gfortran.dg/pr96024.f9011
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 427f901..2780c82 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -14892,6 +14892,19 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
c->ts.u.cl->length ? &c->ts.u.cl->length->where : &c->loc);
return false;
}
+
+ if (c->ts.u.cl->length && c->ts.u.cl->length->ts.type != BT_INTEGER)
+ {
+ if (!c->ts.u.cl->length->error)
+ {
+ gfc_error ("Character length expression of component %qs at %L "
+ "must be of INTEGER type, found %s",
+ c->name, &c->ts.u.cl->length->where,
+ gfc_basic_typename (c->ts.u.cl->length->ts.type));
+ c->ts.u.cl->length->error = 1;
+ }
+ return false;
+ }
}
if (c->ts.type == BT_CHARACTER && c->ts.deferred
diff --git a/gcc/testsuite/gfortran.dg/pr96024.f90 b/gcc/testsuite/gfortran.dg/pr96024.f90
new file mode 100644
index 0000000..2c914a9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96024.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/96024 - ICE in mio_name_expr_t
+! Contributed by G.Steinmetz
+
+module m
+ implicit none
+ type t
+ character(char(1)) :: a ! { dg-error "must be of INTEGER type" }
+ end type
+ type(t) :: z = t('a')
+end