https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115653
--- Comment #2 from Ghorban M. Tavakoly <gmt3141 at gmail dot com> ---
Thank you Steve for your response. I don't have much knowledge of the gcc
codebase, but after your comment and hours of code review and trial and error
I've come to the conclusion that this situation is difficult to handle without
adding a field to gfc_use_list.
Here's my three-line solution. I hope it's correct:
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index cafd3ab53fe..b15e794d91c 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2190,6 +2190,7 @@ typedef struct gfc_use_list
bool only_flag;
struct gfc_use_rename *rename;
locus where;
+ bool from_submodule_decl;
/* Next USE statement. */
struct gfc_use_list *next;
}
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index eda0bc9e299..1bfcb7455d2 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -790,6 +790,7 @@ gfc_match_submodule (void)
use_list = gfc_get_use_list ();
use_list->where = gfc_current_locus;
+ use_list->from_submodule_decl = true;
if (module_list)
{
@@ -7671,7 +7672,7 @@ gfc_use_module (gfc_use_list *module)
only_flag = module->only_flag;
current_intmod = INTMOD_NONE;
- if (!only_flag)
+ if (!only_flag && !module->from_submodule_decl)
gfc_warning_now (OPT_Wuse_without_only,
"USE statement at %C has no ONLY qualifier");