From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E3DF397200A; Thu, 26 Nov 2020 17:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E3DF397200A From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98016] Host association problem Date: Thu, 26 Nov 2020 17:33:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 17:33:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98016 --- Comment #5 from kargl at gcc dot gnu.org --- Index: gcc/gcc/fortran/expr.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/gcc/fortran/expr.c (revision 280157) +++ gcc/gcc/fortran/expr.c (working copy) @@ -3380,24 +3382,41 @@ check_restricted (gfc_expr *e) This mechanism also does the same for the specification expressions of array-valued functions. */ if (e->error - || sym->attr.in_common - || sym->attr.use_assoc - || sym->attr.dummy - || sym->attr.implied_index - || sym->attr.flavor =3D=3D FL_PARAMETER - || is_parent_of_current_ns (sym->ns) - || (sym->ns->proc_name !=3D NULL - && sym->ns->proc_name->attr.flavor =3D=3D FL_MODULE) - || (gfc_is_formal_arg () && (sym->ns =3D=3D gfc_current_ns))) + || sym->attr.in_common + || sym->attr.use_assoc + || sym->attr.dummy + || sym->attr.implied_index + || sym->attr.flavor =3D=3D FL_PARAMETER + || is_parent_of_current_ns (sym->ns) + || (sym->ns->proc_name !=3D NULL + && sym->ns->proc_name->attr.flavor =3D=3D FL_MODULE) + || (gfc_is_formal_arg () && (sym->ns =3D=3D gfc_current_ns))) { t =3D true; break; } - gfc_error ("Variable %qs cannot appear in the expression at %L", - sym->name, &e->where); - /* Prevent a repetition of the error. */ - e->error =3D 1; + for (gfc_namespace *ns =3D sym->ns->parent; ns; ns =3D ns->parent) + if (sym->ns =3D=3D ns) + { + t =3D true; + break; + } + + for (gfc_namespace *ns =3D sym->ns->contained->parent; ns; ns =3D ns->parent) + if (sym->ns =3D=3D ns) + { + t =3D true; + break; + } + + if (!t) + { + gfc_error ("Variable %qs cannot appear in the expression at %L", + sym->name, &e->where); + /* Prevent a repetition of the error. */ + e->error =3D 1; + } break; case EXPR_NULL:=