mescc: Support struct definition with variable declaration.

* module/language/c99/compiler.mes (ast->info): Support `struct foo {} bar;'.
This commit is contained in:
Jan Nieuwenhuizen 2017-05-06 09:27:28 +02:00
parent 68528219cb
commit 5246de5e39
1 changed files with 7 additions and 0 deletions

View File

@ -1683,6 +1683,13 @@
(let ((type (struct->type (list "struct" name) (map struct-field fields))))
(clone info #:types (append (.types info) (list type)))))
;; struct foo {} bar;
((decl (decl-spec-list (type-spec (struct-def (ident ,type) (field-list . ,fields))))
(init-declr-list (init-declr (ident ,name))))
(let ((info ((ast->info info) `(decl (decl-spec-list (type-spec (struct-def (ident ,type) (field-list . ,fields))))))))
((ast->info info)
`(decl (decl-spec-list (type-spec (struct-ref (ident ,type)))) (init-declr-list (init-declr (ident ,name)))))))
;; char *p = &bla;
((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ptr-declr (pointer) (ident ,name)) (initzer (ref-to (p-expr (ident ,value)))))))
(let ((type (decl->type type)))