]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]
authorHarald Anlauf <anlauf@gmx.de>
Tue, 7 Oct 2025 19:54:45 +0000 (21:54 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 8 Oct 2025 18:20:09 +0000 (20:20 +0200)
commit50959e53e40ae087ee7bdbce7229b4b8b3cd1bb6
tree056d8bb127b522f51201b571131b071d1bf83678
parentd4077ce639a2e5f8a12e531aa84fcf631aa5ba34
Fortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]

The Fortran standard does not prohibit restricting the accessibility of a
symbol by use of the PRIVATE attribute and exposing it via a C binding
label.  Instead of unconditionally generating a warning, only warn if the
binding label is surprisingly identical to the privatized Fortran symbol
and when -Wsurprising is specified.

PR fortran/49111

gcc/fortran/ChangeLog:

* decl.cc (verify_bind_c_sym): Modify condition for generation of
accessibility warning, and adjust warning message.

gcc/testsuite/ChangeLog:

* gfortran.dg/binding_label_tests_9.f03: Adjust test.
* gfortran.dg/module_private_2.f90: Likewise.
* gfortran.dg/public_private_module_2.f90: Likewise.
* gfortran.dg/binding_label_tests_35.f90: New test.
gcc/fortran/decl.cc
gcc/testsuite/gfortran.dg/binding_label_tests_35.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/binding_label_tests_9.f03
gcc/testsuite/gfortran.dg/module_private_2.f90
gcc/testsuite/gfortran.dg/public_private_module_2.f90