On Wed, 28 Feb 2024 21:29:06 -0800
Jerry D <jvdelis...@gmail.com> wrote:

> The attached patch adds the error checks similar to the first patch 
> previously committed.
> 
> I noticed a redundancy in some defines MSGLEN and IOMSG_LEN so I 
> consolidated this to one define in io.h. This is just cleanup stuff.
> 
> I have added test cases for each of the places where UDTIO is done in 
> the library.
> 
> Regressions tested on x86_64.
> 
> OK for trunk?

I think the commit hooks will complain about several missing spaces
before open brace; See contrib/check_GNU_style.py /tmp/pr105456-3.diff

Would it make sense to introduce and use an internal helper like trim()?
Or would it be possible to trim the message in generate_error_common()?

And, just for my own education, the length limitation of iomsg to 255
chars is not backed by the standard AFAICS, right? It's just our
STRERR_MAXSZ?

thanks!

> 
> Regards,
> 
> Jerry
> 
> commit 640991bd6b83df4197b2eaec63d1e0e695e48b75
> Author: Jerry DeLisle <jvdeli...@gcc.gnu.org>
> Date:   Wed Feb 28 20:51:06 2024 -0800
> 
>      Fortran: Add user defined error messages for UDTIO.
> 
>      The defines IOMSG_LEN and MSGLEN were redundant so these are combined
>      into IOMSG_LEN as defined in io.h.
> 
>      The remainder of the patch adds checks for when a user defined
>      derived type IO procedure sets the IOSTAT or IOMSG variables
>      independent of the librrary defined I/O messages.
> 
>              PR libfortran/105456
> 
>      libgfortran/ChangeLog:
> 
>              * io/io.h (IOMSG_LEN): Moved to here.
>              * io/list_read.c (MSGLEN): Removed MSGLEN.
>              (convert_integer): Changed MSGLEN to IOMSG_LEN.
>              (parse_repeat): Likewise.
>              (read_logical): Likewise.
>              (read_integer): Likewise.
>              (read_character): Likewise.
>              (parse_real): Likewise.
>              (read_complex): Likewise.
>              (read_real): Likewise.
>              (check_type): Likewise.
>              (list_formatted_read_scalar): Adjust to IOMSG_LEN.
>              (nml_read_obj): Add user defined error message.
>              * io/transfer.c (unformatted_read): Add user defined error
>              message.
>              (unformatted_write): Add user defined error message.
>              (formatted_transfer_scalar_read): Add user defined error 
> message.
>              (formatted_transfer_scalar_write): Add user defined error 
> message.
>              * io/write.c (list_formatted_write_scalar): Add user 
> defined error message.
>              (nml_write_obj): Add user defined error message.
> 
>      gcc/testsuite/ChangeLog:
> 
>              * gfortran.dg/pr105456-nmlr.f90: New test.
>              * gfortran.dg/pr105456-nmlw.f90: New test.
>              * gfortran.dg/pr105456-ruf.f90: New test.
>              * gfortran.dg/pr105456-wf.f90: New test.
>              * gfortran.dg/pr105456-wuf.f90: New test.

Reply via email to