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
1 changed files with 10 additions and 6 deletions

View File

@ -2101,12 +2101,16 @@
((initzer (p-expr (fixed ,fixed)))
(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)
(begin
(stderr "array-init-element->data: oops:~s\n" o)
(stderr "type:~s\n" type)
(error "array-init-element->data: not supported: " o))))
(if (structured-type? type)
(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)
(error "array-init-element->data: not supported: " o))))
(_ (init->data type o info))
(_ (error "array-init-element->data: not supported: " o))))