forked from alex-eg/sex
write #() as {0}
{} is C23's. #() is all zeros, which C11 spells {0}, whatever it
initializes.
This commit is contained in:
@@ -359,13 +359,16 @@ forms, and what remains."
|
||||
;;; language. `:' is the separator because it is the one thing that can
|
||||
;;; be neither a type word nor an expression -- a named form would be a
|
||||
;;; C identifier, and so shadowable (see issue #36).
|
||||
;;;
|
||||
;;; #() is all zeros, and C11 spells that {0}: {} came in only with C23
|
||||
(define (walk-initializer elements)
|
||||
(let ((parts (list-split (remove comment-form? elements) ':)))
|
||||
(let ((parts (list-split (remove comment-form? elements) ':))
|
||||
(filled (lambda (es) (if (null? es) (list 0) (walk-designators es)))))
|
||||
(if (null? (cdr parts))
|
||||
(list->vector (walk-designators (car parts)))
|
||||
(list->vector (filled (car parts)))
|
||||
(cons* '%compound
|
||||
(walk-type (maybe-unwrap-type (car parts)))
|
||||
(walk-designators (cadr parts))))))
|
||||
(filled (cadr parts))))))
|
||||
|
||||
;;; `.field value' is a designated initializer; anything else is
|
||||
;;; positional. C lets the two be mixed, and nothing here stops it. A
|
||||
|
||||
Reference in New Issue
Block a user