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

--- Comment #7 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:c45c5ee3f5c51c00153173f7416946c05ce1b172

commit r17-2424-gc45c5ee3f5c51c00153173f7416946c05ce1b172
Author: Thomas Koenig <[email protected]>
Date:   Tue Jul 14 18:58:36 2026 +0200

    Fix some more issues with -Wunused-but-set and -Wundefined-vars.

    The root cause for PR 126058 that was that sym->extra_loc was not
    being set for possible allocations via allocatablearguments. Looking
    at the code, a few more problems became clear:  Not only INTENT(OUT)
    arguments could allocate allocatables, all other INTENTS could do so
    as well, but only if the formal arguments are allocatable as well.
    Also, curent intrinsics do not have allocatable components.

    During testing, there were also a few cases where, if one warning with
    -Wall and one with -Wextra applied, the one with -Wextra was issued
peferably.
    This is slightly confusing, and also fixed with this patch.

    gcc/fortran/ChangeLog:

            PR fortran/126058
            * gfortran.h (enum var_allocated): New enum.
            (symbol_attribute): Change member allocated to new enum.
            (gfc_used_in_allocate_expr): Add argument how.
            * interface.cc (gfc_compare_actual_formal): Mark variables
            as allocated only when the formal arg is allocatable.
            * intrinsic.cc (mark_args_as_used): Intrinsics do not allocate
            their arguments.
            * resolve.cc (find_unused_vs_set): Move warnings enabled with
            -Wextra behind those enabled with -Wall. If a variable is
            maybe allocated as an argument, mark it as such.
            * symbol.cc (mark_vars_as_used): Always set location.
            (gfc_used_in_allocate_expr): Add argument how. Use it.
            (gfc_lvalue_allocated_at): Set sym->attr.allocated to
ALLOCATED_ASSIGNMENT.

    gcc/testsuite/ChangeLog:

            PR fortran/126058
            * gfortran.dg/warn_undefined_vars_7.f90: New test.
            * gfortran.dg/warn_unused_but_set_variable_4.f90: New test.

Reply via email to