A recent change to the checking of legacy FORMAT tags did not handle cases where the type is not set. Adjust the check.
Regtested on x86_64-pc-linux-gnu. OK for mainline / 11- / 10-branch? Thanks, Harald Fortran: reject FORMAT tag of unknown type. gcc/fortran/ChangeLog: PR fortran/101084 * io.c (resolve_tag_format): Extend FORMAT check to unknown type. gcc/testsuite/ChangeLog: PR fortran/101084 * gfortran.dg/fmt_nonchar_3.f90: New test.
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 40cd76eb585..fc97df79eca 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1763,7 +1763,7 @@ resolve_tag_format (gfc_expr *e) if (e->ts.type != BT_CHARACTER) { if (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS - || e->ts.type == BT_VOID) + || e->ts.type == BT_VOID || e->ts.type == BT_UNKNOWN) { gfc_error ("Non-character non-Hollerith in FORMAT tag at %L", &e->where); diff --git a/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90 b/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90 new file mode 100644 index 00000000000..3b3c260ef7f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/101084 + +program p + integer, parameter :: a(0) = 1 + print int(a) ! { dg-error "Non-character non-Hollerith in FORMAT tag" } +end