public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10559] Fortran: reject invalid CHARACTER length of derived type components [PR96024]
@ 2023-03-05 19:35 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-03-05 19:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7db643a17e8c862b4c758fd69d62a45c6de43d38
commit r11-10559-g7db643a17e8c862b4c758fd69d62a45c6de43d38
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Feb 21 22:06:33 2023 +0100
Fortran: reject invalid CHARACTER length of derived type components [PR96024]
gcc/fortran/ChangeLog:
PR fortran/96024
* resolve.c (resolve_component): The type of a CHARACTER length
expression must be INTEGER.
gcc/testsuite/ChangeLog:
PR fortran/96024
* gfortran.dg/pr96024.f90: New test.
(cherry picked from commit 31303c9b5bab200754cdb7ef8cd91ae4918f3018)
Diff:
---
gcc/fortran/resolve.c | 13 +++++++++++++
gcc/testsuite/gfortran.dg/pr96024.f90 | 11 +++++++++++
2 files changed, 24 insertions(+)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 29125694e1e..18e766494f2 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14747,6 +14747,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 00000000000..2c914a997f2
--- /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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-05 19:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-05 19:35 [gcc r11-10559] Fortran: reject invalid CHARACTER length of derived type components [PR96024] Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).