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, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2909 invoked from network); 14 May 2023 11:15:24 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 14 May 2023 11:15:24 -0000 Received: from one.net.tachibana-labs.org ([78.141.198.89]) by 9front; Sun May 14 07:10:19 -0400 2023 Received: from localhost (one.net.tachibana-labs.org [local]) by one.net.tachibana-labs.org (OpenSMTPD) with ESMTPA id 1430c8ee for <9front@9front.org>; Sun, 14 May 2023 11:10:17 +0000 (UTC) Date: Sun, 14 May 2023 11:10:17 +0000 From: mia soweli To: 9front@9front.org Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: virtualized shared persistence storage storage Subject: [9front] [PATCH] cc: support type qualifiers inside array brackets. Reply-To: 9front@9front.org Precedence: bulk allows c99 array declarations with type qualifiers inside the brackets. for example: int list[const 5]; int list[const restrict 5]; int list[volatile 5]; int list[static 5]; i am not sure if the handling of static is correct. diff 090af6255bebf0129c891116b53b31808fe49dc7 uncommitted --- a/sys/src/cmd/cc/cc.y +++ b/sys/src/cmd/cc/cc.y @@ -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 @@ { $$ = new(OFUNC, $1, $3); } -| xdecor2 '[' zexpr ']' +| xdecor2 '[' zanlist zexpr ']' { - $$ = new(OARRAY, $1, $3); + $$ = new(OARRAY, $1, $4); + $$->garb = simpleg($3); + $$->class = simplec($3); } /* @@ -273,9 +275,11 @@ { $$ = new(OFUNC, $1, $3); } -| abdecor2 '[' zexpr ']' +| abdecor2 '[' zanlist zexpr ']' { - $$ = new(OARRAY, $1, $3); + $$ = new(OARRAY, $1, $4); + $$->garb = simpleg($3); + $$->class = simplec($3); } abdecor3: @@ -283,9 +287,11 @@ { $$ = new(OFUNC, (Z), Z); } -| '[' zexpr ']' +| '[' zanlist zexpr ']' { - $$ = new(OARRAY, (Z), $2); + $$ = new(OARRAY, (Z), $3); + $$->garb = simpleg($2); + $$->class = simplec($2); } | '(' abdecor1 ')' { @@ -1099,6 +1105,15 @@ $$ = typebitor($1, $2); } +zanlist: + { + $$ = 0; + } +| zanlist aname + { + $$ = typebitor($1, $2); + } + gctname: tname | gname @@ -1152,6 +1167,12 @@ | LVOLATILE { $$ = BVOLATILE; } | LRESTRICT { $$ = 0; } | LNORET { $$ = BNORET; } + +aname: /* words allowed in an array declaration */ + LCONSTNT { $$ = BCONSTNT; } +| LVOLATILE { $$ = BVOLATILE; } +| LRESTRICT { $$ = 0; } +| LSTATIC { $$ = BSTATIC; } name: LNAME