From ebf9b6c13f0847ddcc22e540a5fcdbf644e85a9c Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 16 Feb 2021 14:17:35 +0100 Subject: Fortran: Reject DT as fmt in I/O statments [PR99111] gcc/fortran/ChangeLog: PR fortran/99111 * io.c (resolve_tag_format): Reject BT_DERIVED/CLASS/VOID as (array-valued) FORMAT tag. gcc/testsuite/ChangeLog: PR fortran/99111 * gfortran.dg/fmt_nonchar_1.f90: New test. * gfortran.dg/fmt_nonchar_2.f90: New test. --- gcc/fortran/io.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index da6ad17..40cd76e 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1762,6 +1762,13 @@ resolve_tag_format (gfc_expr *e) It may be assigned an Hollerith constant. */ if (e->ts.type != BT_CHARACTER) { + if (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS + || e->ts.type == BT_VOID) + { + gfc_error ("Non-character non-Hollerith in FORMAT tag at %L", + &e->where); + return false; + } if (!gfc_notify_std (GFC_STD_LEGACY, "Non-character in FORMAT tag " "at %L", &e->where)) return false; -- cgit v1.1