9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] cc: support const and restrict inside array declarations
@ 2023-05-13 23:31 mia soweli
  2023-05-14  5:25 ` ori
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: mia soweli @ 2023-05-13 23:31 UTC (permalink / raw)
  To: 9front

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 ')'
 	{


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-15 14:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [9front] [PATCH] cc: support type qualifiers inside array brackets mia soweli
2023-05-15  7:39   ` [9front] " mia soweli
2023-05-15 12:51     ` ori
2023-05-15 14:05       ` [9front] " mia soweli

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).