From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19368 invoked from network); 15 May 2023 07:42:01 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 15 May 2023 07:42:01 -0000 Received: from one.net.tachibana-labs.org ([78.141.198.89]) by 9front; Mon May 15 03:40:02 -0400 2023 Received: from [127.0.0.1] (82-132-228-104.dab.02.net [82.132.228.104]) by one.net.tachibana-labs.org (OpenSMTPD) with ESMTPSA id e398ad5c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <9front@9front.org>; Mon, 15 May 2023 07:39:56 +0000 (UTC) Date: Mon, 15 May 2023 08:39:55 +0100 From: mia soweli To: 9front@9front.org User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <8F22ED51-F0B5-4DF9-881E-E8BF258DF795@tachibana-labs.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: compliant hardware content-driven manager Subject: [9front] =?US-ASCII?Q?Re=3A_=5B9front=5D_=5BPATCH=5D_cc=3A_support_ty?= =?US-ASCII?Q?pe_qualifiers_inside_array_brackets=2E?= Reply-To: 9front@9front.org Precedence: bulk allows c99 array declarations with type qualifiers inside the brackets=2E for example: int list[const 5]; int list[const restrict 5]; int list[volatile 5]; int list[static 5]; i read the standard more closely, the static seems to be an optimization t= hing that means the array has *at least* however many members, and we shoul= d ignore it instead of treating it like static outside the brackets=2E diff 090af6255bebf0129c891116b53b31808fe49dc7 uncommitted --- a/sys/src/cmd/cc/cc=2Ey +++ b/sys/src/cmd/cc/cc=2Ey @@ -27,8 +27,8 @@ vlong vval; } %type ltag -%type gctname gcname cname gname tname -%type gctnlist gcnlist zgnlist +%type gctname gcname cname gname tname aname +%type gctnlist gcnlist zgnlist zanlist %type tlist sbody complex %type types %type zarglist arglist zcexpr @@ -142,9 +142,11 @@ { $$ =3D new(OFUNC, $1, $3); } -| xdecor2 '[' zexpr ']' +| xdecor2 '[' zanlist zexpr ']' { - $$ =3D new(OARRAY, $1, $3); + $$ =3D new(OARRAY, $1, $4); + $$->garb =3D simpleg($3); } /* @@ -273,9 +275,11 @@ { $$ =3D new(OFUNC, $1, $3); } -| abdecor2 '[' zexpr ']' +| abdecor2 '[' zanlist zexpr ']' { - $$ =3D new(OARRAY, $1, $3); + $$ =3D new(OARRAY, $1, $4); + $$->garb =3D simpleg($3); } abdecor3: @@ -283,9 +287,11 @@ { $$ =3D new(OFUNC, (Z), Z); } -| '[' zexpr ']' +| '[' zanlist zexpr ']' { - $$ =3D new(OARRAY, (Z), $2); + $$ =3D new(OARRAY, (Z), $3); + $$->garb =3D simpleg($2); } | '(' abdecor1 ')' { @@ -1099,6 +1105,15 @@ $$ =3D typebitor($1, $2); } +zanlist: + { + $$ =3D 0; + } +| zanlist aname + { + $$ =3D typebitor($1, $2); + } + gctname: tname | gname @@ -1152,6 +1167,12 @@ | LVOLATILE { $$ =3D BVOLATILE; } | LRESTRICT { $$ =3D 0; } | LNORET { $$ =3D BNORET; } + +aname: /* words allowed in an array declaration */ + LCONSTNT { $$ =3D BCONSTNT; } +| LVOLATILE { $$ =3D BVOLATILE; } +| LRESTRICT { $$ =3D 0; } +| LSTATIC { $$ =3D BSTATIC; } name: LNAME