Re: [patch, Fortran] Fix undefined variable warnings related to ASSOCIATE

Paul Richard Thomas <[email protected]> Sat, 1 Aug 2026 14:33:24 +0100
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <CAGkQGiKiuwm_5S5-FwJzhsCprT0jJsa6p1m6c1g1aNs9hMRnsQ@mail.gmail.com>
Hello Thomas,

LGTM. OK for mainline and, I suggest, backporting to 16-branch at least.

Thanks for the patch.

Paul

On Sat, 1 Aug 2026 at 14:26, Thomas Koenig <[email protected]> wrote:
>
> Hello world,
>
> this fixes one of the false positives from the addition of the recent
> -W options, with ASSOCIATE.
>
> Regression-tested. OK for trunk?
>
> Best regards
>
>         Thomas
>
> Fix undefined variable warning related to ASSOCIATE.
>
> This patch fixes unused warnings in ASSOCIATE constructs by setting
> value_used and value_set attributes based on the associate names.
> This is placed after resolution of the code. To get to the association
> list, an extra argument to gfc_resolve was needed.
>
> gcc/fortran/ChangeLog:
>
>         PR fortran/126558
>         * gfortran.h (gfc_resolve): Add optional argument for
>         an association list.
>         * resolve.cc (mark_assoc_used): New function.
>         (gfc_resolve): Use it.
>
> gcc/testsuite/ChangeLog:
>
>         PR fortran/126558
>         * gfortran.dg/warn_undefined_vars_10.f90: New test.