* [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]
@ 2023-01-28 17:07 Harald Anlauf
2023-01-28 20:03 ` Steve Kargl
2023-01-28 20:04 ` Jerry D
0 siblings, 2 replies; 3+ messages in thread
From: Harald Anlauf @ 2023-01-28 17:07 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
Dear all,
a USE associated symbol shall not appear in a COMMON block
(F2018:C8121) and needs to be diagnosed. The patch is
fairly obvious.
Regtested on x86_64-pc-linux-gnu. OK for mainline?
As the PR is marked as a 10/11/12/13 regression,
I plan to backport as appropriate.
Thanks,
Harald
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr108453.diff --]
[-- Type: text/x-patch, Size: 2052 bytes --]
From 3f0e4b23038ade2cd14d93b0705af93848ee45c2 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Sat, 28 Jan 2023 17:59:23 +0100
Subject: [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks
[PR108453]
gcc/fortran/ChangeLog:
PR fortran/108453
* match.cc (gfc_match_common): A USE associated name shall not appear
in a COMMON block (F2018:C8121).
gcc/testsuite/ChangeLog:
PR fortran/108453
* gfortran.dg/common_27.f90: New test.
---
gcc/fortran/match.cc | 10 ++++++++++
gcc/testsuite/gfortran.dg/common_27.f90 | 14 ++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/common_27.f90
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 5e933c12931..5eb6d0e1c1d 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -5345,6 +5345,16 @@ gfc_match_common (void)
goto cleanup;
}
+ /* F2018:R874: common-block-object is variable-name [ (array-spec) ]
+ F2018:C8121: A variable-name shall not be a name made accessible
+ by use association. */
+ if (sym->attr.use_assoc)
+ {
+ gfc_error ("Symbol %qs at %C is USE associated from module %qs "
+ "and cannot occur in COMMON", sym->name, sym->module);
+ goto cleanup;
+ }
+
/* Deal with an optional array specification after the
symbol name. */
m = gfc_match_array_spec (&as, true, true);
diff --git a/gcc/testsuite/gfortran.dg/common_27.f90 b/gcc/testsuite/gfortran.dg/common_27.f90
new file mode 100644
index 00000000000..dcde5de2bd2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_27.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! PR fortran/108453 - a use associated variable cannot occur in COMMON
+! Contributed by G.Steinmetz
+
+module m
+ type t
+ end type
+ real :: r
+end
+program p
+ use m, only: t, r
+ common t ! { dg-error "USE associated from module" }
+ common /cm/ r ! { dg-error "USE associated from module" }
+end
--
2.35.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]
2023-01-28 17:07 [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] Harald Anlauf
@ 2023-01-28 20:03 ` Steve Kargl
2023-01-28 20:04 ` Jerry D
1 sibling, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2023-01-28 20:03 UTC (permalink / raw)
To: Harald Anlauf via Fortran; +Cc: gcc-patches
On Sat, Jan 28, 2023 at 06:07:50PM +0100, Harald Anlauf via Fortran wrote:
>
> a USE associated symbol shall not appear in a COMMON block
> (F2018:C8121) and needs to be diagnosed. The patch is
> fairly obvious.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
> As the PR is marked as a 10/11/12/13 regression,
> I plan to backport as appropriate.
>
Yes. Backports are fine with a clean regression test.
Thanks for the patch and your continued attack on
bugzilla issues.
--
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]
2023-01-28 17:07 [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] Harald Anlauf
2023-01-28 20:03 ` Steve Kargl
@ 2023-01-28 20:04 ` Jerry D
1 sibling, 0 replies; 3+ messages in thread
From: Jerry D @ 2023-01-28 20:04 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
On 1/28/23 9:07 AM, Harald Anlauf via Fortran wrote:
> Dear all,
>
> a USE associated symbol shall not appear in a COMMON block
> (F2018:C8121) and needs to be diagnosed. The patch is
> fairly obvious.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
> As the PR is marked as a 10/11/12/13 regression,
> I plan to backport as appropriate.
>
> Thanks,
> Harald
>
Yes, this is OK for all.
Thanks
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-28 20:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 17:07 [PATCH] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] Harald Anlauf
2023-01-28 20:03 ` Steve Kargl
2023-01-28 20:04 ` Jerry D
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).