Fortran: reject FORMAT tag of unknown type.
authorHarald Anlauf <anlauf@gmx.de>
Sun, 18 Jul 2021 19:35:53 +0000 (21:35 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Sun, 18 Jul 2021 19:35:53 +0000 (21:35 +0200)
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.

gcc/fortran/io.c
gcc/testsuite/gfortran.dg/fmt_nonchar_3.f90 [new file with mode: 0644]

index 40cd76e..fc97df7 100644 (file)
@@ -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 (file)
index 0000000..3b3c260
--- /dev/null
@@ -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