https://gcc.gnu.org/g:0cfe86380b58b21f014b57d3964b904ba93008df
commit r17-1256-g0cfe86380b58b21f014b57d3964b904ba93008df Author: Paul Thomas <[email protected]> Date: Wed Jun 3 12:02:03 2026 +0100 Fortran: Wuse-without-only bogus warning for submodules [PR105594] 2026-06-03 Steven G. Kargl <[email protected]> gcc/fortran PR fortran/105594 * module.cc (gfc_use_module): Suppress bogus warning for a missing ONLY clause on a submodule. gcc/testsuite/ PR fortran/105594 * gfortran.dg/pr105594.f90: New test. Diff: --- gcc/fortran/module.cc | 2 +- gcc/testsuite/gfortran.dg/pr105594.f90 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index fa560f7ef467..99e162431d42 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -7671,7 +7671,7 @@ gfc_use_module (gfc_use_list *module) only_flag = module->only_flag; current_intmod = INTMOD_NONE; - if (!only_flag) + if (!only_flag && gfc_state_stack->state != COMP_SUBMODULE) gfc_warning_now (OPT_Wuse_without_only, "USE statement at %C has no ONLY qualifier"); diff --git a/gcc/testsuite/gfortran.dg/pr105594.f90 b/gcc/testsuite/gfortran.dg/pr105594.f90 new file mode 100644 index 000000000000..9cd5310bbada --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr105594.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-Wuse-without-only" } +! PR105594: Spurious warning when compiled with -Wuse-without-only +! +! Contributed by Brad Richardson <[email protected]> +! +module foo_m + interface + module subroutine foo + end subroutine + end interface +end module + +submodule (foo_m) foo_s +contains + module procedure foo + end procedure +end submodule
