designate an initializer's element by its index

[3] in braces reached the writer as a subscript of one operand, and
sexc died taking the second.
This commit is contained in:
2026-10-18 22:02:55 +03:00
parent 18962f43ad
commit 72adb5284b
4 changed files with 26 additions and 3 deletions

View File

@@ -322,6 +322,7 @@
((%sizeof-type) ((cat "sizeof(" (c-type (cadr x)) ")") st))
((%compound) ((apply c-compound (cdr x)) st))
((%designate) ((apply c-designate (cdr x)) st))
((%designate-index) ((apply c-designate-index (cdr x)) st))
((+ - & * / % ! ~ ^ && < > <= >= == != << >>
= *= /= %= &= ^= >>= <<=) ; |\|| |\|\|| |\|=|
((apply c-op x) st))
@@ -927,6 +928,10 @@
(define (c-designate field value)
(cat "." (c-expr field) " = " (c-expr value)))
;; MODIFIED FROM UPSTREAM fmt-c, which designates fields only
(define (c-designate-index index value)
(cat "[" (c-expr index) "] = " (c-expr value)))
(define (c-typedef type alias . o)
(c-wrap-stmt
(cat "typedef " (c-type type alias) (fmt-join/prefix c-expr o " "))))