gcc/fortran/ChangeLog:
PR fortran/108453
* match.c (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)
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);
--- /dev/null
+! { 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