From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7679A385151B; Thu, 27 Oct 2022 14:25:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7679A385151B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666880748; bh=vlzFOK2BVD9YFwPiXrAla8rdMxjNHyU7o5f8/aT2rj4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xg4QNR0GkSEUQsh4+Rfz51OXhU9rc76pHFagR6+5xgIZSJSAKpJ/JmE1tPg213Enx afSS5vhZYOmw5gb4FQCMZrwBSj4LJ3LguyHpp3SAd9PIUKLhMt7rg4fWoOmVNk3W3A RwR4Yl7xasLfZKGuxyWdeeo74Na2rVjhIM/u/H8M= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107406] lock_type Date: Thu, 27 Oct 2022 14:25:47 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on priority cc everconfirmed 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107406 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2022-10-27 Priority|P3 |P4 CC| |kargl at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to Damian Rouson from comment #0) > gfortran 12.2 accepts the code below if the "allocatable" attribute is > removed: >=20 > % cat gfortran-lock-issue.f90=20 > use iso_fortran_env > type foo > type(lock_type), allocatable :: bar > end type > type(foo) foobar[*] > end >=20 > % gfortran -fcoarray=3Dsingle gfortran-lock-issue.f90=20 > gfortran-lock-issue.f90:3:39: >=20 > 3 | type(lock_type), allocatable :: bar > | 1 > Error: Allocatable component bar at (1) of type LOCK_TYPE must have a > codimension >=20 > The NAG compiler accepts the above code and I believe constraint C1608 in > the Fortran 2018 standard makes the above code valid. >=20 > Is this related to PR 92122? Yes, it is likely related. The code that gives rise to the error is trying to check F2008:C1302. C1302 A named variable of type LOCK_TYPE shall be a coarray. A named variable with a noncoarray sub-component of type LOCK_TYPE shall be a coarray. I think the 2nd sentence has been misinterpreted. The named variable is fo= obar and it is a coarray. bar is a component of derived type and is not a named variable. In the parlance of Fortran, bar is a subobject and is referred t= o as an object designator. The same applies to PR92122. The following patch allows your example to compile with 'gfortran -fcoarray=3Dsingle a.f90'. diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index f04fd13cc69..8440f58ef23 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -3339,7 +3339,7 @@ check_component (gfc_symbol *sym, gfc_component *c, gfc_component **lockp, "of type LOCK_TYPE, which must have a codimension or be a " "subcomponent of a coarray", c->name, &c->loc); - if (lock_type && allocatable && !coarray) + if (lock_type && allocatable && !coarray && !lock_comp) gfc_error ("Allocatable component %s at %L of type LOCK_TYPE must have= " "a codimension", c->name, &c->loc); else if (lock_type && allocatable && c->ts.type =3D=3D BT_DERIVED Note, the section of code is prefaced with the following comment /* Check for F2008, C1302 - and recall that pointers may not be coarrays (5.3.14) and that subobjects of coarray are coarray themselves (2.4.7), unless there are nondirect [allocatable or pointer] components involved (cf. 1.3.33.1 and 1.3.33.3). */ Someone who knows coarrays needs to verify the veracity of the comment.=