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

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

https://gcc.gnu.org/g:3a26cb6c0082a7ca1d0399e8c545df1138e91a18

commit r16-9105-g3a26cb6c0082a7ca1d0399e8c545df1138e91a18
Author: Jerry DeLisle <[email protected]>
Date:   Fri Jun 5 10:20:36 2026 -0700

    fortran: ASSOCIATE with contained-function selector rejecting type-bound
calls

    Two issues prevented ASSOCIATE constructs whose selector is a call to a
    contained function from subsequently calling type-bound procedures on the
    associate name.

    When the selector is a contained function, resolving it
    at parse time (before CONTAINS is fully processed) prematurely set the
    function's attribute to FL_PROCEDURE/EXTERNAL, conflicting with its later
    declaration as an internal procedure and giving a spurious "attribute
    conflict" error.

    When the first access is a generic type-bound procedure name, no candidate
    type was found, and the associate name got no type, giving "no IMPLICIT
type".
    Now also search type-bound procedure names via gfc_find_typebound_proc;
exclude vtable
    types to avoid false positives.

    Assisted-by: Claude Sonnet 4.6

            PR fortran/125530

    gcc/fortran/ChangeLog:

            * match.cc (gfc_match_call): Route ASSOCIATE names followed by '%'
            to match_typebound_call without first resolving the selector, to
            avoid prematurely marking a contained-function selector as
EXTERNAL.
            * symbol.cc (find_derived_types): Also search type-bound procedure
            names via gfc_find_typebound_proc when inferring the type of an
            inferred-type ASSOCIATE name; exclude vtable types.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/associate_contained_func_typebound.f90: New test.
            * gfortran.dg/associate_contained_func_typebound_2.f90: New
            run-time test exercising generic resolution and a module-scope
            selector.

    (cherry picked from commit 3ea639715f6076dbdda113e9330924262e938164)

Reply via email to