public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule
@ 2023-10-19 15:11 zed.three at gmail dot com
  2023-10-19 16:06 ` [Bug fortran/111880] " kargl at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zed.three at gmail dot com @ 2023-10-19 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111880
           Summary: [9/10/11/12/13] False positive warning of obsolescent
                    COMMON block with Fortran submodule
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zed.three at gmail dot com
  Target Milestone: ---

Created attachment 56152
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56152&action=edit
Minimal source code demonstrating issue.

Compiler Explorer link with complete reproducer:
https://godbolt.org/z/dd45enhWe

  module third_party_module
    integer :: some_param
    common /not_my_code/ some_param
  end module third_party_module

  module foo
    use third_party_module
    interface
      module subroutine bar()
      end subroutine bar
    end interface
  end module foo

  submodule (foo) foo_submod
  contains
    module procedure bar
    end procedure bar
  end submodule foo_submod


Compiling the above minimal program like:

  gfortran -std=f2018 -c foo.f90


gives the following warnings:

  foo.f90:3:22:

      3 |   common /not_my_code/ some_param
        |                      1
  Warning: Fortran 2018 obsolescent feature: COMMON block at (1)
  foo.f90:14:14:

     14 | submodule (foo) foo_submod
        |              1
  Warning: Fortran 2018 obsolescent feature: COMMON block at (1)


The first warning is expected, but the second one is a false positive. I came
across this when building with a library outside of my control, so I cannot
remove the problem common block (actually this was with MPI, and it happens
with all the major implementations as the common block is required for
technical reasons).


If the submodule is removed, the extra warning disappears. The warning also
appears when building the submodule separately (in a different file and having
already built the parent module).

It also only appears to be this warning, and not other F2018 obsolescent
feature warnings (e.g. labeled DO statements), or other warnings enabled at
`-Wall` for instance.

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

* [Bug fortran/111880] [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
@ 2023-10-19 16:06 ` kargl at gcc dot gnu.org
  2023-10-19 17:20 ` zed.three at gmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-10-19 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Priority|P3                          |P5

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to zed.three from comment #0)
>  Warning: Fortran 2018 obsolescent feature: COMMON block at (1)
>   foo.f90:14:14:
>   
>      14 | submodule (foo) foo_submod
>         |              1
>   Warning: Fortran 2018 obsolescent feature: COMMON block at (1)
> 

Not sure I would call this a false positive as the 
locus is pointing at module 'foo', and 'foo' contains
a common block.

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

* [Bug fortran/111880] [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
  2023-10-19 16:06 ` [Bug fortran/111880] " kargl at gcc dot gnu.org
@ 2023-10-19 17:20 ` zed.three at gmail dot com
  2023-10-19 17:32 ` sgk at troutmask dot apl.washington.edu
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: zed.three at gmail dot com @ 2023-10-19 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from zed.three at gmail dot com ---
The common block is in 'third_party_module', rather than 'foo', unless you mean
that it is visible from 'foo'? It is still a surprising warning in this
location at any rate!

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

* [Bug fortran/111880] [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
  2023-10-19 16:06 ` [Bug fortran/111880] " kargl at gcc dot gnu.org
  2023-10-19 17:20 ` zed.three at gmail dot com
@ 2023-10-19 17:32 ` sgk at troutmask dot apl.washington.edu
  2023-10-20  6:48 ` [Bug fortran/111880] [11/12/13/14] " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2023-10-19 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Oct 19, 2023 at 05:20:46PM +0000, zed.three at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111880
> 
> --- Comment #2 from zed.three at gmail dot com ---
> The common block is in 'third_party_module', rather than 'foo',
> unless you mean that it is visible from 'foo'?

Exactly. 'not_my_code' is in the namespace for foo
through use association of third_party_module. 
It seems that trying to hide 'not_my_code' with PRIVATE
or 'use third_party_module, only : some_param' in foo 
does not mute the warning.  Likely, due to -std=f2018
and F2018, Sec. 4.2.

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (2 preceding siblings ...)
  2023-10-19 17:32 ` sgk at troutmask dot apl.washington.edu
@ 2023-10-20  6:48 ` rguenth at gcc dot gnu.org
  2023-11-23 21:20 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-20  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12/13] False       |[11/12/13/14] False
                   |positive warning of         |positive warning of
                   |obsolescent COMMON block    |obsolescent COMMON block
                   |with Fortran submodule      |with Fortran submodule
   Target Milestone|---                         |11.5

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (3 preceding siblings ...)
  2023-10-20  6:48 ` [Bug fortran/111880] [11/12/13/14] " rguenth at gcc dot gnu.org
@ 2023-11-23 21:20 ` anlauf at gcc dot gnu.org
  2023-11-23 21:42 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-23 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #4 from anlauf at gcc dot gnu.org ---
Potential fix:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 81a14653a04..962274f5d25 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -986,8 +986,8 @@ resolve_common_vars (gfc_common_head *common_block, bool
named_common)

       /* gfc_add_in_common may have been called before, but the reported
errors
         have been ignored to continue parsing.
-        We do the checks again here.  */
-      if (!csym->attr.use_assoc)
+        We do the checks again here, unless the symbol is USE associated.  */
+      if (!csym->attr.use_assoc && !csym->attr.used_in_submodule)
        {
          gfc_add_in_common (&csym->attr, csym->name, &common_block->where);
          gfc_notify_std (GFC_STD_F2018_OBS, "COMMON block at %L",

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (4 preceding siblings ...)
  2023-11-23 21:20 ` anlauf at gcc dot gnu.org
@ 2023-11-23 21:42 ` anlauf at gcc dot gnu.org
  2023-11-23 22:00 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-23 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #4)
> Potential fix:

Regtests ok.

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (5 preceding siblings ...)
  2023-11-23 21:42 ` anlauf at gcc dot gnu.org
@ 2023-11-23 22:00 ` anlauf at gcc dot gnu.org
  2023-11-26 19:20 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-23 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-11-23
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #6 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-November/059954.html

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (6 preceding siblings ...)
  2023-11-23 22:00 ` anlauf at gcc dot gnu.org
@ 2023-11-26 19:20 ` cvs-commit at gcc dot gnu.org
  2023-11-30 21:21 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-26 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:c9d029ba2ceb435e31492c1f3f0fd3edf0e386be

commit r14-5859-gc9d029ba2ceb435e31492c1f3f0fd3edf0e386be
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Nov 23 22:48:38 2023 +0100

    Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]

    gcc/fortran/ChangeLog:

            PR fortran/111880
            * resolve.cc (resolve_common_vars): Do not call gfc_add_in_common
            for symbols that are USE associated or used in a submodule.

    gcc/testsuite/ChangeLog:

            PR fortran/111880
            * gfortran.dg/pr111880.f90: New test.

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (7 preceding siblings ...)
  2023-11-26 19:20 ` cvs-commit at gcc dot gnu.org
@ 2023-11-30 21:21 ` cvs-commit at gcc dot gnu.org
  2023-12-01 18:00 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-30 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:ff96ddf43bcfe5c37a85118a68dcac87ce33c8d9

commit r13-8111-gff96ddf43bcfe5c37a85118a68dcac87ce33c8d9
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Nov 23 22:48:38 2023 +0100

    Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]

    gcc/fortran/ChangeLog:

            PR fortran/111880
            * resolve.cc (resolve_common_vars): Do not call gfc_add_in_common
            for symbols that are USE associated or used in a submodule.

    gcc/testsuite/ChangeLog:

            PR fortran/111880
            * gfortran.dg/pr111880.f90: New test.

    (cherry picked from commit c9d029ba2ceb435e31492c1f3f0fd3edf0e386be)

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (8 preceding siblings ...)
  2023-11-30 21:21 ` cvs-commit at gcc dot gnu.org
@ 2023-12-01 18:00 ` cvs-commit at gcc dot gnu.org
  2023-12-01 18:04 ` cvs-commit at gcc dot gnu.org
  2023-12-01 18:05 ` anlauf at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-01 18:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:17cbec6e8ea8817b6240837bb1f1bf74f1b9bdcd

commit r12-10022-g17cbec6e8ea8817b6240837bb1f1bf74f1b9bdcd
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Nov 23 22:48:38 2023 +0100

    Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]

    gcc/fortran/ChangeLog:

            PR fortran/111880
            * resolve.cc (resolve_common_vars): Do not call gfc_add_in_common
            for symbols that are USE associated or used in a submodule.

    gcc/testsuite/ChangeLog:

            PR fortran/111880
            * gfortran.dg/pr111880.f90: New test.

    (cherry picked from commit c9d029ba2ceb435e31492c1f3f0fd3edf0e386be)

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (9 preceding siblings ...)
  2023-12-01 18:00 ` cvs-commit at gcc dot gnu.org
@ 2023-12-01 18:04 ` cvs-commit at gcc dot gnu.org
  2023-12-01 18:05 ` anlauf at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-01 18:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:246760b37f1239b3b97c20fb4a914f21154389a3

commit r11-11119-g246760b37f1239b3b97c20fb4a914f21154389a3
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Nov 23 22:48:38 2023 +0100

    Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]

    gcc/fortran/ChangeLog:

            PR fortran/111880
            * resolve.c (resolve_common_vars): Do not call gfc_add_in_common
            for symbols that are USE associated or used in a submodule.

    gcc/testsuite/ChangeLog:

            PR fortran/111880
            * gfortran.dg/pr111880.f90: New test.

    (cherry picked from commit c9d029ba2ceb435e31492c1f3f0fd3edf0e386be)

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

* [Bug fortran/111880] [11/12/13/14] False positive warning of obsolescent COMMON block with Fortran submodule
  2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
                   ` (10 preceding siblings ...)
  2023-12-01 18:04 ` cvs-commit at gcc dot gnu.org
@ 2023-12-01 18:05 ` anlauf at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-01 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from anlauf at gcc dot gnu.org ---
Fixed on all open branches.  Closing.

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

end of thread, other threads:[~2023-12-01 18:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 15:11 [Bug fortran/111880] New: [9/10/11/12/13] False positive warning of obsolescent COMMON block with Fortran submodule zed.three at gmail dot com
2023-10-19 16:06 ` [Bug fortran/111880] " kargl at gcc dot gnu.org
2023-10-19 17:20 ` zed.three at gmail dot com
2023-10-19 17:32 ` sgk at troutmask dot apl.washington.edu
2023-10-20  6:48 ` [Bug fortran/111880] [11/12/13/14] " rguenth at gcc dot gnu.org
2023-11-23 21:20 ` anlauf at gcc dot gnu.org
2023-11-23 21:42 ` anlauf at gcc dot gnu.org
2023-11-23 22:00 ` anlauf at gcc dot gnu.org
2023-11-26 19:20 ` cvs-commit at gcc dot gnu.org
2023-11-30 21:21 ` cvs-commit at gcc dot gnu.org
2023-12-01 18:00 ` cvs-commit at gcc dot gnu.org
2023-12-01 18:04 ` cvs-commit at gcc dot gnu.org
2023-12-01 18:05 ` anlauf at gcc dot gnu.org

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).