https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83135
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Harald Anlauf <anl...@gcc.gnu.org>: https://gcc.gnu.org/g:3c130e410ac45d1bfca0c9d584603b726f58e0ac commit r15-5533-g3c130e410ac45d1bfca0c9d584603b726f58e0ac Author: Harald Anlauf <anl...@gmx.de> Date: Wed Nov 20 21:59:22 2024 +0100 Fortran: fix checking of protected variables in submodules [PR83135] When a symbol was use-associated in the ancestor of a submodule, a PROTECTED attribute was ignored in the submodule or its descendants. Find the real ancestor of symbols when used in a variable definition context in a submodule. PR fortran/83135 gcc/fortran/ChangeLog: * expr.cc (sym_is_from_ancestor): New helper function. (gfc_check_vardef_context): Refine checking of PROTECTED attribute of symbols that are indirectly use-associated in a submodule. gcc/testsuite/ChangeLog: * gfortran.dg/protected_10.f90: New test.