* [PATCH] Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]
@ 2023-11-23 21:59 Harald Anlauf
2023-11-26 18:58 ` Mikael Morin
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2023-11-23 21:59 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
Dear all,
the PR is about a redundant obsolescence warning for COMMON when
a symbols appears in the scope of a submodule. As we did not warn
for use-associated symbols, it seemed natural to extend this to
symbols that are used in a submodule. Or am I missing anything?
Regtests cleanly on x86_64-pc-linux-gnu. OK for mainline?
The PR is marked as a regression (the warning appeared in gcc-9).
It looks simple enough for backporting, or does anybody see any
risk here?
Thanks,
Harald
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr111880.diff --]
[-- Type: text/x-patch, Size: 2316 bytes --]
From a962ab0417f5ff2efd51e710ae370d9f4a4b9f1a Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Thu, 23 Nov 2023 22:48:38 +0100
Subject: [PATCH] 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.
---
gcc/fortran/resolve.cc | 4 ++--
gcc/testsuite/gfortran.dg/pr111880.f90 | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr111880.f90
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 81a14653a04..166b702cd9a 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",
diff --git a/gcc/testsuite/gfortran.dg/pr111880.f90 b/gcc/testsuite/gfortran.dg/pr111880.f90
new file mode 100644
index 00000000000..c0cd98a93d4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr111880.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+! PR fortran/111880 - redundant warning of obsolescent COMMON with submodule
+
+module third_party_module
+ integer :: some_param
+ common /not_my_code/ some_param ! { dg-warning "COMMON block" }
+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 ! We do not need a warning here!
+contains
+ module procedure bar
+ end procedure bar
+end submodule foo_submod
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fortran: avoid obsolescence warning for COMMON with submodule [PR111880]
2023-11-23 21:59 [PATCH] Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] Harald Anlauf
@ 2023-11-26 18:58 ` Mikael Morin
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Morin @ 2023-11-26 18:58 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
Hello,
Le 23/11/2023 à 22:59, Harald Anlauf a écrit :
> Dear all,
>
> the PR is about a redundant obsolescence warning for COMMON when
> a symbols appears in the scope of a submodule. As we did not warn
> for use-associated symbols, it seemed natural to extend this to
> symbols that are used in a submodule. Or am I missing anything?
>
> Regtests cleanly on x86_64-pc-linux-gnu. OK for mainline?
>
Yes, looks good. Obvious I'm tempted to say.
> The PR is marked as a regression (the warning appeared in gcc-9).
> It looks simple enough for backporting, or does anybody see any
> risk here?
>
No, you can go ahead.
Thanks
Mikael
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-26 18:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 21:59 [PATCH] Fortran: avoid obsolescence warning for COMMON with submodule [PR111880] Harald Anlauf
2023-11-26 18:58 ` Mikael Morin
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).