From 841e585ad936624f2d080512a9f6244b49e71969 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 28 Jan 2023 17:59:23 +0100 Subject: Fortran: diagnose USE associated symbols in COMMON blocks [PR108453] 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) --- gcc/fortran/match.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/fortran') diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 7d06e0e..cd27ff7 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -5297,6 +5297,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); -- cgit v1.1