From: mia soweli <inbox@tachibana-labs.org>
To: 9front@9front.org
Subject: [9front] [PATCH] cc: support type qualifiers inside array brackets.
Date: Sun, 14 May 2023 11:10:17 +0000 [thread overview]
Message-ID: <ZGDBmZ9ELIWFDqzF@one.net.tachibana-labs.org> (raw)
In-Reply-To: <ZGAd4S2sAhvK8lSJ@one.net.tachibana-labs.org>
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 <sym> ltag
-%type <lval> gctname gcname cname gname tname
-%type <lval> gctnlist gcnlist zgnlist
+%type <lval> gctname gcname cname gname tname aname
+%type <lval> gctnlist gcnlist zgnlist zanlist
%type <type> tlist sbody complex
%type <tycl> types
%type <node> 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
next prev parent reply other threads:[~2023-05-14 11:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-13 23:31 [9front] [PATCH] cc: support const and restrict inside array declarations mia soweli
2023-05-14 5:25 ` ori
2023-05-14 10:20 ` [9front] " mia soweli
2023-05-14 8:10 ` Michael Forney
2023-05-14 10:23 ` [9front] " mia soweli
2023-05-14 11:10 ` mia soweli [this message]
2023-05-15 7:39 ` [9front] Re: [9front] [PATCH] cc: support type qualifiers inside array brackets mia soweli
2023-05-15 12:51 ` ori
2023-05-15 14:05 ` [9front] " mia soweli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZGDBmZ9ELIWFDqzF@one.net.tachibana-labs.org \
--to=inbox@tachibana-labs.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).