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

--- Comment #11 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:7efa7b77d2e341d0036727474cd45e66cb6c3445

commit r16-9546-g7efa7b77d2e341d0036727474cd45e66cb6c3445
Author: Jerry DeLisle <[email protected]>
Date:   Fri Aug 14 12:20:35 2026 -0700

    fortran: [PR126872] BIND(C) entities must keep default ELF visibility

    Assisted-by: Claude Opus 5

    A binding label gives an entity external linkage, so PRIVATE hides only
    the Fortran name and must not lower the symbol's ELF visibility.  Three
    sites gave hidden visibility to PRIVATE module entities without exempting
    binding labels, so a BIND(C) procedure or variable in a module with a
    PRIVATE default was not exported from a shared library.

    The procedure case is a regression from r17-913 (PR fortran/125430),
    backported to the 16 branch as r16-9113 and so present in 16.2.0 but not
    16.1.0; the variable case dates from r6-2637, the introduction of
    submodules (PR fortran/52846).  Module entities
    without a binding label keep the hidden visibility that lets submodules
    reach them via host association.

    gcc/fortran/ChangeLog:

            PR fortran/126872
            * trans-decl.cc (gfc_finish_var_decl): Drop the unreachable
            hidden-visibility case in the BIND(C) block.  Do not give hidden
            visibility to a PRIVATE module variable with a binding label.
            (build_function_decl): Do not give hidden visibility to a PRIVATE
            module procedure with a binding label.

    gcc/testsuite/ChangeLog:

            PR fortran/126872
            * gfortran.dg/bind_c_private_1.f90: New test.

    (cherry picked from commit 75136eabafd2028a04d47720ea87548df47e2578)

Reply via email to