Hi all,

attached is another simple patch for an accepts-invalid problem (this
time concerning DTIO), also curing an invalid test case.

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus



2018-02-15  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/84409
    * interface.c (check_dtio_arg_TKR_intent): Add a check for character
    length.


2018-02-15  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/84409
    * gfortran.dg/dtio_21.f03: Add an error message.
    * gfortran.dg/dtio_22.f90: Fix invalid test case.
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c     (revision 257672)
+++ gcc/fortran/interface.c     (working copy)
@@ -4702,6 +4702,10 @@ check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool
     gfc_error ("DTIO dummy argument at %L must be an "
               "ASSUMED SHAPE ARRAY", &fsym->declared_at);
 
+  if (type == BT_CHARACTER && fsym->ts.u.cl->length != NULL)
+    gfc_error ("DTIO character argument at %L must have assumed length",
+               &fsym->declared_at);
+
   if (fsym->attr.intent != intent)
     gfc_error ("DTIO dummy argument at %L must have INTENT %s",
               &fsym->declared_at, gfc_code2string (intents, (int)intent));
Index: gcc/testsuite/gfortran.dg/dtio_21.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dtio_21.f90       (revision 257672)
+++ gcc/testsuite/gfortran.dg/dtio_21.f90       (working copy)
@@ -19,10 +19,10 @@ program p
    allocate(z2)
    print *, z2
   contains
-   subroutine wf2(this, a, b, c, d, e)
+   subroutine wf2(this, a, b, c, d, e)  ! { dg-error "must have assumed 
length" }
       class(t2), intent(in) :: this
       integer, intent(in) :: a
-      character, intent(in) :: b
+      character(*), intent(in) :: b
       integer, intent(in) :: c(:)
       integer, intent(out) :: d
       character, intent(inout) :: e
Index: gcc/testsuite/gfortran.dg/dtio_22.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dtio_22.f90       (revision 257672)
+++ gcc/testsuite/gfortran.dg/dtio_22.f90       (working copy)
@@ -15,10 +15,10 @@ contains
   subroutine wf(this, unit, b, c, iostat, iomsg)
     class(t), intent(in) :: this
     integer, intent(in) :: unit
-    character, intent(in) :: b
+    character(*), intent(in) :: b
     integer, intent(in) :: c(:)
     integer, intent(out) :: iostat
-    character, intent(inout) :: iomsg
+    character(*), intent(inout) :: iomsg
     write (unit, "(i3)", IOSTAT=iostat, IOMSG=iomsg) this%i
   end subroutine
 end

Reply via email to