Fortran: reject invalid CHARACTER length of derived type components [PR96024]
gcc/fortran/ChangeLog: PR fortran/96024 * resolve.cc (resolve_component): The type of a CHARACTER length expression must be INTEGER. gcc/testsuite/ChangeLog: PR fortran/96024 * gfortran.dg/pr96024.f90: New test.
This commit is contained in:
parent
5344482c4d
commit
31303c9b5b
2 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
11
gcc/testsuite/gfortran.dg/pr96024.f90
Normal file
11
gcc/testsuite/gfortran.dg/pr96024.f90
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue