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 11211 invoked from network); 13 May 2023 23:36:00 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 13 May 2023 23:36:00 -0000 Received: from one.net.tachibana-labs.org ([78.141.198.89]) by 9front; Sat May 13 19:31:58 -0400 2023 Received: from localhost (one.net.tachibana-labs.org [local]) by one.net.tachibana-labs.org (OpenSMTPD) with ESMTPA id aff4f808 for <9front@9front.org>; Sat, 13 May 2023 23:31:45 +0000 (UTC) Date: Sat, 13 May 2023 23:31:45 +0000 From: mia soweli To: 9front@9front.org Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: secure blockchain firewall element-oriented layer Subject: [9front] [PATCH] cc: support const and restrict inside array declarations Reply-To: 9front@9front.org Precedence: bulk this allows c23 style array declarations (see c23 draft section 6.7.6), with type qualifiers inside the brackets. for example: const int list[restrict 4]; int list[const 4]; int list[const restrict 4]; int list[volatile 4]; int list[noret 4]; /* we may not want to allow this */ they are ignored as with other uses of const, restrict, and volatile. it does not allow int list[static 4]; which is also allowed in c23. diff 090af6255bebf0129c891116b53b31808fe49dc7 uncommitted --- a/sys/src/cmd/cc/cc.y +++ b/sys/src/cmd/cc/cc.y @@ -142,9 +142,9 @@ { $$ = new(OFUNC, $1, $3); } -| xdecor2 '[' zexpr ']' +| xdecor2 '[' zgnlist zexpr ']' { - $$ = new(OARRAY, $1, $3); + $$ = new(OARRAY, $1, $4); } /* @@ -273,9 +273,9 @@ { $$ = new(OFUNC, $1, $3); } -| abdecor2 '[' zexpr ']' +| abdecor2 '[' zgnlist zexpr ']' { - $$ = new(OARRAY, $1, $3); + $$ = new(OARRAY, $1, $4); } abdecor3: @@ -283,9 +283,9 @@ { $$ = new(OFUNC, (Z), Z); } -| '[' zexpr ']' +| '[' zgnlist zexpr ']' { - $$ = new(OARRAY, (Z), $2); + $$ = new(OARRAY, (Z), $3); } | '(' abdecor1 ')' {