https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45129

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:968c113104289b007760c2a9814ff736b43e590f

commit r17-6662-g968c113104289b007760c2a9814ff736b43e590f
Author: Jerry DeLisle <[email protected]>
Date:   Mon Nov 23 10:26:43 2026 -0800

    fortran: [PR45129] Warn on too-small real output field widths

    A D, E, EN, ES, F or G edit descriptor on output whose width is too
    small for its digits always produces asterisks, but gfortran gave no
warning at
    compile time.  check_format now warns about it under the new option
    -Wformat-width, which -Wall enables.

    A labeled FORMAT is checked when it is matched, before a READ or
    WRITE refers to it, so its I/O direction is not yet known.
    check_format takes a format_check_kind: that first pass skips the
    width warnings, and gfc_resolve_dt reruns the check for the width
    warnings alone the first time the FORMAT is used for output, with the
    other diagnostics suppressed.

    Assisted-by: Claude Opus 5.5

            PR fortran/45129

    gcc/fortran/ChangeLog:

            * gfortran.h (gfc_st_label): Add output_width_checked.
            * invoke.texi (-Wformat-width): Document.
            (-Wall): List -Wformat-width.
            * io.cc (checking_width_only): New.
            (next_char_not_space): Skip the tab warning when it is set.
            (format_asterisk): Initialize output_width_checked.
            (f_min_width, check_real_width): New.
            (format_check_kind): New enum.
            (check_format): Add a format_check_kind argument.  Skip the width
            warnings for FMT_CHECK_DECL and the other warnings for
            FMT_CHECK_WIDTH.  Warn with -Wformat-width when a D, E, EN, ES, F
            or G field width on output is too small for its digits.
            (check_format_string): Add a format_check_kind argument.  For
            FMT_CHECK_WIDTH, suppress errors and skip the check for trailing
            characters.
            (gfc_match_format): Pass FMT_CHECK_DECL.
            (gfc_resolve_dt): With -Wformat-width, recheck a labeled FORMAT
            with FMT_CHECK_WIDTH the first time it is used for output.
            * lang.opt (Wformat-width): New.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr45129.f90: New test.

Reply via email to