From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailrelay.tugraz.at (mailrelay.tugraz.at [129.27.2.202]) by sourceware.org (Postfix) with ESMTPS id 5E3113849AC0 for ; Wed, 10 Apr 2024 19:05:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E3113849AC0 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=tugraz.at Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tugraz.at ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5E3113849AC0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.27.2.202 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712775967; cv=none; b=nuBBn2lKaoraZCXPnniFOj8ilfrjJOPflfpaGahddrL0VtfBNwngiGexZXm5O9yh/pnX4WlsD42LqbbsVmr8iXpqJVbK0AxJYEWok2YM4PU3PRk7dWNRUTDBLDAKdxFfpTbs8iMhG3nrMbv6zdwCPSLxXCBQi9Wwb0uqv6wx0oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712775967; c=relaxed/simple; bh=zUj1FUGRhTczUcdypi3ud7owqU8+d4s96Bki/TwPmgw=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=V47DEEVaeOTVvnVEpP4a1LbS2PAfXMg6wn4WB9ZCb9HcfbsjjmKUjybSNeWTm9junuAMRoZ0zl3OVzywlzHc+Rn+oza9oSMyclEYzcHxb2K3cgl7phWf6AWOwIPSQfRlkDFDdh/i/0tvdU+IxPpWLsDagNQ9hKX7R2qGA03lmU8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [192.168.0.221] (84-115-223-216.cable.dynamic.surfer.at [84.115.223.216]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4VFC350mPsz3wBg; Wed, 10 Apr 2024 21:05:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1712775953; bh=D4smBbkykc9Xf0yqVYYNs5glFlDebvesdB2bW6Yl1Ss=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UrKcz3fd1s+QhEpVEu4PRZLu0//r4EwzXjtqp3+e/Q4vh6Xy6v/EL/jgcZJhyufu/ P4+TqEa9lkVOH3f+tJptg4maRX1J8M1EqLNkZ30hJzjueosS7uehESZFt9WrVx4Ymp +zXBSsykZERtX41R2XPpD14roVtFmEZiu3BY50EA= Message-ID: Subject: Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896) From: Martin Uecker To: Joseph Myers , Qing Zhao Cc: richard.guenther@gmail.com, siddhesh@gotplt.org, keescook@chromium.org, isanbard@gmail.com, gcc-patches@gcc.gnu.org Date: Wed, 10 Apr 2024 21:05:52 +0200 In-Reply-To: <7516d9f96d842f9316b7623b6851ee32caf74264.camel@tugraz.at> References: <20240329160703.4012941-1-qing.zhao@oracle.com> <20240329160703.4012941-2-qing.zhao@oracle.com> <7516d9f96d842f9316b7623b6851ee32caf74264.camel@tugraz.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-TUG-Backscatter-control: G/VXY7/6zeyuAY/PU2/0qw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Am Mittwoch, dem 10.04.2024 um 20:25 +0200 schrieb Martin Uecker: > Am Mittwoch, dem 10.04.2024 um 17:35 +0000 schrieb Joseph Myers: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >=20 > > > + /* Issue error when there is a counted_by attribute with a differe= nt > > > + field as the argument for the same flexible array member field.= */ > >=20 > > There's another case of this to consider, though I'm not sure where bes= t=20 > > to check for it (Martin might have suggestions) - of course this case w= ill=20 > > need testcases as well. > >=20 > > Suppose, as allowed in C23, a structure is defined twice in the same= =20 > > scope, but the two definitions of the structure use inconsistent=20 > > counted_by attributes. I'd say that, when the declarations are in the= =20 > > same scope (thus required to be consistent), it should be an error for = the=20 > > two definitions of what is meant to be the same structure to use=20 > > incompatible counted_by attributes (even though the member declarations= =20 > > are otherwise the same). >=20 > I think the right place could be comp_types_attributes in > attributes.cc. It may be sufficient to set the > affects_type_identify flag. >=20 > This should then give a redefinition error as it should do for > "packed". Thinking about this a bit more, this will not work here, because the counted_by attribute is not applied to the struct type but one of the members. So probably there should be a check added directly to tagged_types_tu_compatible_p Martin >=20 > >=20 > > In C23 structures defined with the same tag in different scopes are=20 > > compatible given requirements including compatible types for correspond= ing=20 > > elements. It would seem most appropriate to me for such structures wit= h=20 > > incompatible counted_by attributes to be considered *not* compatible ty= pes=20 > > (but it would be valid to define structures with the same tag, differen= t=20 > > scopes, and elements the same except for counted_by - just not to use t= hem=20 > > in any way requiring them to be compatible). >=20 > Another option might be to warn about the case when those types > are then used together in a way where they are required to > be compatible. Then comp_types_attributes would have to return 2. >=20 >=20 > Martin >=20 > >=20 > > > +The @code{counted_by} attribute may be attached to the C99 flexible = array > > > +member of a structure. It indicates that the number of the elements= of the > > > +array is given by the field "@var{count}" in the same structure as t= he > >=20 > > As noted previously, the "" quotes should be removed there (or replaced= by=20 > > ``'' quotes). > >=20 >=20