public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/115653] New: USE without ONLY warning when compiling submodules
@ 2024-06-25 20:48 gmt3141 at gmail dot com
  2024-06-25 20:58 ` [Bug fortran/115653] " kargls at comcast dot net
  0 siblings, 1 reply; 2+ messages in thread
From: gmt3141 at gmail dot com @ 2024-06-25 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115653
           Summary: USE without ONLY warning when compiling submodules
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gmt3141 at gmail dot com
  Target Milestone: ---

When I compile a submodule with `-Wuse-without-only` option, a false positive
warning about USE without ONLY will be shown:

$ gfortran -Wuse-without-only greeting.f90
greeting.f90:13:19:

   13 | submodule (greet_m) greet_implementation_sm
      |                   1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! greeting.f90
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

module greet_m

  implicit none

  interface
     module subroutine hello (name)
       character (len=*), intent (in), optional :: name
     end subroutine hello
  end interface

end module greet_m

submodule (greet_m) greet_implementation_sm

contains

  module subroutine hello (name)
    character (len=*), intent (in), optional :: name

    if (present (name)) then
       print '("Hello ", a, "!")', name
    else
       print '("Hello World!")'
    end if
  end subroutine hello

end submodule greet_implementation_sm

program greeting

  use greet_m, only: hello

  implicit none

  call hello
  call hello ('John')

end program greeting

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug fortran/115653] USE without ONLY warning when compiling submodules
  2024-06-25 20:48 [Bug fortran/115653] New: USE without ONLY warning when compiling submodules gmt3141 at gmail dot com
@ 2024-06-25 20:58 ` kargls at comcast dot net
  0 siblings, 0 replies; 2+ messages in thread
From: kargls at comcast dot net @ 2024-06-25 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

kargls at comcast dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargls at comcast dot net

--- Comment #1 from kargls at comcast dot net ---
Thanks for the bug report.  Fortunately, it is only warning that clutters the
terminal.

This patch suppresses the warning, but may not catch a 'USE xyz'
within the submodule.

diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index c565b84d61b..5a58a9dbace 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -7285,7 +7285,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");

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-25 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-25 20:48 [Bug fortran/115653] New: USE without ONLY warning when compiling submodules gmt3141 at gmail dot com
2024-06-25 20:58 ` [Bug fortran/115653] " kargls at comcast dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).