mescc: Tinycc support: Handle short struct initializer.

* module/language/c99/compiler.mes (array-init-element->data): Handle
  short struct initializer.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-22 18:24:32 +02:00
parent 029c000840
commit 932b38980e
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -2102,7 +2102,11 @@
(int->bv type (expr->number info fixed)))
((initzer (initzer-list . ,inits))
(if (structured-type? type)
(map (cut init->data <> <> info) (map cdr (struct->init-fields type)) inits)
(let* ((fields (map cdr (struct->init-fields type)))
(missing (max 0 (- (length fields) (length inits))))
(inits (append inits
(map (const '(fixed "0")) (iota missing)))))
(map (cut init->data <> <> info) fields inits))
(begin
(stderr "array-init-element->data: oops:~s\n" o)
(stderr "type:~s\n" type)