* [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len
@ 2018-02-15 20:04 Janus Weil
2018-02-15 20:16 ` Steve Kargl
0 siblings, 1 reply; 5+ messages in thread
From: Janus Weil @ 2018-02-15 20:04 UTC (permalink / raw)
To: gfortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]
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 <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.
[-- Attachment #2: pr84409.diff --]
[-- Type: text/plain, Size: 2068 bytes --]
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len
2018-02-15 20:04 [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len Janus Weil
@ 2018-02-15 20:16 ` Steve Kargl
2018-02-15 20:56 ` Janus Weil
0 siblings, 1 reply; 5+ messages in thread
From: Steve Kargl @ 2018-02-15 20:16 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran, gcc-patches
On Thu, Feb 15, 2018 at 09:03:55PM +0100, Janus Weil wrote:
>
> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>
Looks good to me with a question below.
> 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 the above is a numbered constraint in the Standard,
can you add a comment of the form /* F03:C1111. */
above the if-statement.
--
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len
2018-02-15 20:16 ` Steve Kargl
@ 2018-02-15 20:56 ` Janus Weil
2018-02-15 21:03 ` Steve Kargl
0 siblings, 1 reply; 5+ messages in thread
From: Janus Weil @ 2018-02-15 20:56 UTC (permalink / raw)
To: Steve Kargl; +Cc: gfortran, gcc-patches
2018-02-15 21:16 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Thu, Feb 15, 2018 at 09:03:55PM +0100, Janus Weil wrote:
>>
>> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>>
>
> Looks good to me with a question below.
Thanks for the feedback, Steve.
>> 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 the above is a numbered constraint in the Standard,
> can you add a comment of the form /* F03:C1111. */
> above the if-statement.
Well, the if statement that I'm adding is not covered by a single
clause in the standard. Instead the DTIO interfaces are described as a
whole in a chapter, whose number I'm now adding in the comment above
the function:
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 257672)
+++ gcc/fortran/interface.c (working copy)
@@ -4673,7 +4673,7 @@ gfc_check_typebound_override (gfc_symtree* proc, g
/* 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
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));
Will commit this shortly.
Cheers,
Janus
2018-02-15 21:16 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Thu, Feb 15, 2018 at 09:03:55PM +0100, Janus Weil wrote:
>>
>> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>>
>
> Looks good to me with a question below.
>
>> 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 the above is a numbered constraint in the Standard,
> can you add a comment of the form /* F03:C1111. */
> above the if-statement.
>
> --
> Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len
2018-02-15 20:56 ` Janus Weil
@ 2018-02-15 21:03 ` Steve Kargl
2018-02-15 21:17 ` Janus Weil
0 siblings, 1 reply; 5+ messages in thread
From: Steve Kargl @ 2018-02-15 21:03 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran, gcc-patches
On Thu, Feb 15, 2018 at 09:55:58PM +0100, Janus Weil wrote:
> 2018-02-15 21:16 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> >
> > If the above is a numbered constraint in the Standard,
> > can you add a comment of the form /* F03:C1111. */
> > above the if-statement.
>
> Well, the if statement that I'm adding is not covered by a single
> clause in the standard. Instead the DTIO interfaces are described as a
> whole in a chapter, whose number I'm now adding in the comment above
> the function:
Thanks. The source code has become sufficiently complicated
that a small comment references the Standard simply aids (me)
in debugging/reading the code.
--
Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len
2018-02-15 21:03 ` Steve Kargl
@ 2018-02-15 21:17 ` Janus Weil
0 siblings, 0 replies; 5+ messages in thread
From: Janus Weil @ 2018-02-15 21:17 UTC (permalink / raw)
To: Steve Kargl; +Cc: gfortran, gcc-patches
2018-02-15 22:03 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Thu, Feb 15, 2018 at 09:55:58PM +0100, Janus Weil wrote:
>> 2018-02-15 21:16 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
>> >
>> > If the above is a numbered constraint in the Standard,
>> > can you add a comment of the form /* F03:C1111. */
>> > above the if-statement.
>>
>> Well, the if statement that I'm adding is not covered by a single
>> clause in the standard. Instead the DTIO interfaces are described as a
>> whole in a chapter, whose number I'm now adding in the comment above
>> the function:
>
> Thanks. The source code has become sufficiently complicated
> that a small comment references the Standard simply aids (me)
> in debugging/reading the code.
Absolutely. It's important to provide clear links between the standard
and the implementation.
I have committed the patch as r257711.
Cheers,
Janus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-15 21:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 20:04 [Patch, Fortran, F03] PR 84409: check DTIO arguments for character len Janus Weil
2018-02-15 20:16 ` Steve Kargl
2018-02-15 20:56 ` Janus Weil
2018-02-15 21:03 ` Steve Kargl
2018-02-15 21:17 ` Janus Weil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).