public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9101] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]
@ 2023-02-02 21:01 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-02-02 21:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:936fdf056944989c49dc4fff399ca5dc0d0213ee
commit r12-9101-g936fdf056944989c49dc4fff399ca5dc0d0213ee
Author: Harald Anlauf <anlauf@gmx.de>
Date: Sat Jan 28 17:59:23 2023 +0100
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.
(cherry picked from commit aba9ff8f30d4245294ea2583de1dc28f1c7ccf7b)
Diff:
---
gcc/fortran/match.cc | 10 ++++++++++
gcc/testsuite/gfortran.dg/common_27.f90 | 14 ++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 205811bb969..673662e9087 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -5339,6 +5339,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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-02 21:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 21:01 [gcc r12-9101] Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] Harald Anlauf
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).