https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114475
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Mikael Morin <mik...@gcc.gnu.org>: https://gcc.gnu.org/g:7f233feafd657250340be3b3500d2697948ae3ed commit r14-9703-g7f233feafd657250340be3b3500d2697948ae3ed Author: Mikael Morin <mik...@gcc.gnu.org> Date: Wed Mar 27 16:30:42 2024 +0100 fortran: Fix specification expression check in submodules [PR114475] The patch fixing PR111781 made the check of specification expressions more restrictive, disallowing local variables in specification expressions of dummy arguments. PR114475 showed an example where that change regressed, disallowing in submodules expressions that had been allowed in the parent module. In submodules indeed, the hierarchy of namespaces inherited from the parent module is not reproduced so the host-association of symbols can't be recognized by checking the nesting of namespaces. This change fixes the problem by allowing in specification expressions all the symbols in a submodule that are inherited from the parent module. PR fortran/111781 PR fortran/114475 gcc/fortran/ChangeLog: * expr.cc (check_restricted): In submodules, allow variables host- associated from the parent module. gcc/testsuite/ChangeLog: * gfortran.dg/spec_expr_10.f90: New test. Co-authored-by: Harald Anlauf <anl...@gmx.de>