I've created a patch to fix bug 115653, USE without ONLY warning when
compiling submodules.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115653

The patch:

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");


Regards

-- 
Ghorban M. Tavakoly
Phone number: +98 (902) (2²⁰+2¹⁹+2¹⁸+…+2²+2¹+2⁰)

Reply via email to