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

--- Comment #17 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Thomas Koenig <[email protected]>:

https://gcc.gnu.org/g:9861e3f70ee0909a814a0cfeb8cc7166d062cb20

commit r17-1666-g9861e3f70ee0909a814a0cfeb8cc7166d062cb20
Author: Thomas Koenig <[email protected]>
Date:   Sun Jun 14 08:43:00 2026 +0200

    Mark variables in references for variable definition context as used.

    Code like "a(i) = 42" would not mark i as used, leading to false
    positives for warnings with -Wunused-but-set-variable.  This is fixed
    in the attached patch.  It also removes some default arguments to
    make sure that the caller side provides correct information.

    gcc/fortran/ChangeLog:

            PR fortran/30438
            * gfortran.h (gfc_value_set_at): Remove default argument.
            (gfc_expr_set_at): Add prototype.
            * interface.cc (gfc_compare_actual_formal): Use gfc_expr_set_at.
            * intrinsic.cc (mark_args_as_used): Likewise.
            * io.cc (resolve_tag): Likewise.
            (gfc_resolve_dt): Likewise.
            (gfc_resolve_inquire): Likewise.
            * resolve.cc (resolve_transfer): Likewise.
            (mark_lhs_assignments_set): Likewise.
            * symbol.cc (gfc_lvalue_allocated_at): Add comment, fix formatting.
            (gfc_expr_set_at): New fuction.

    gcc/testsuite/ChangeLog:

            PR fortran/30438
            * gfortran.dg/warn_unused_but_set_variable_2.f90: New test.

Reply via email to