aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanus Weil <janus@gcc.gnu.org>2018-02-15 22:16:00 +0100
committerJanus Weil <janus@gcc.gnu.org>2018-02-15 22:16:00 +0100
commitf3ad8745b0559b3abc4253dbc3a659295b142379 (patch)
tree0045b7dc9a42f86c8ce13179f571cc71a04c5754
parent51f174c0efe187d46102bf8010d6096cada1a0cb (diff)
downloadgcc-f3ad8745b0559b3abc4253dbc3a659295b142379.zip
gcc-f3ad8745b0559b3abc4253dbc3a659295b142379.tar.gz
gcc-f3ad8745b0559b3abc4253dbc3a659295b142379.tar.bz2
re PR fortran/84409 ([F03] check DTIO arguments for character len)
2018-02-15 Janus Weil <janus@gcc.gnu.org> PR fortran/84409 * interface.c (check_dtio_arg_TKR_intent): Add a check for character length. 2018-02-15 Janus Weil <janus@gcc.gnu.org> PR fortran/84409 * gfortran.dg/dtio_21.f03: Add an error message. * gfortran.dg/dtio_22.f90: Fix invalid test case. From-SVN: r257711
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/interface.c6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/dtio_21.f904
-rw-r--r--gcc/testsuite/gfortran.dg/dtio_22.f904
5 files changed, 21 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ed91bf7..481004e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-15 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/84409
+ * interface.c (check_dtio_arg_TKR_intent): Add a check for character
+ length.
+
2018-02-14 Janus Weil <janus@gcc.gnu.org>
PR fortran/84385
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index a5f3f4d..ad02928 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -4673,7 +4673,7 @@ gfc_check_typebound_override (gfc_symtree* proc, gfc_symtree* old)
/* The following three functions check that the formal arguments
of user defined derived type IO procedures are compliant with
- the requirements of the standard. */
+ the requirements of the standard, see F03:9.5.3.7.2 (F08:9.6.4.8.3). */
static void
check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool typebound, bt type,
@@ -4702,6 +4702,10 @@ check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool typebound, bt type,
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));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4892192..aceed33 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-15 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/84409
+ * gfortran.dg/dtio_21.f03: Add an error message.
+ * gfortran.dg/dtio_22.f90: Fix invalid test case.
+
2018-02-15 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84381
diff --git a/gcc/testsuite/gfortran.dg/dtio_21.f90 b/gcc/testsuite/gfortran.dg/dtio_21.f90
index 8bfe3aa..e8d433c 100644
--- a/gcc/testsuite/gfortran.dg/dtio_21.f90
+++ b/gcc/testsuite/gfortran.dg/dtio_21.f90
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/dtio_22.f90 b/gcc/testsuite/gfortran.dg/dtio_22.f90
index f39450c..152a96a 100644
--- a/gcc/testsuite/gfortran.dg/dtio_22.f90
+++ b/gcc/testsuite/gfortran.dg/dtio_22.f90
@@ -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