https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121379
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Paul Thomas <[email protected]>: https://gcc.gnu.org/g:3872da84760f827365fc0f8d1fdc45ca25810f89 commit r17-1405-g3872da84760f827365fc0f8d1fdc45ca25810f89 Author: Paul Thomas <[email protected]> Date: Sun Jun 7 15:11:20 2026 +0100 Fortran: require MODULE prefix for separate module procedures [PR121379] set_syms_host_assoc clears the 'external' attribute on module procedures when making them accessible via host association in a submodule. The existing check in get_proc_name for a missing MODULE prefix used 'sym->attr.external' as a guard, so the diagnostic was silently suppressed and gfortran accepted â and incorrectly linked â a bare function definition as if it were a valid separate module procedure. Replace 'sym->attr.external' with 'sym->attr.module_procedure', which is not cleared by set_syms_host_assoc, to restore the intended diagnostic. Also update the error message to be clearer about what is required. Both errors have been corrected to avoid returning any value, thereby avoiding an error cascade. After all, these are OK for further processing and argument mismatches etc. can be caught. Additionally, a number of existing testcases contained this error. In order to avoid masking the intended fix, this has been corrected in all cases. 2026-06-07 Paul Thomas <[email protected]> gcc/fortran PR fortran/121379 * decl.cc (get_proc_name): Use module_procedure attr. instead of external to guard the missing-MODULE-prefix diagnostic. Use gfc_error_now and do not return, so that an error cascade does not occur. gcc/testsuite/ChangeLog PR fortran/121379 * gfortran.dg/pdt_59.f03: Add module attribute as required. * gfortran.dg/pr87907.f90: Ditto. * gfortran.dg/pr93461.f90: Ditto. * gfortran.dg/submodule_10.f08: Ditto. * gfortran.dg/submodule_33.f08: Ditto. * gfortran.dg/submodule_36.f90: New test. * gfortran.dg/submodule_37.f90: Add module attribute. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
