mescc: Tinycc support: foo.bar[baz], foo->bar[baz] for typedef'd struct bar.

* module/language/c99/compiler.mes (expr->accu): foo.bar[baz],
  foo->bar[baz] for typedef'd struct bar.
* scaffold/tests/7c-dynarray.c: Test it.
This commit is contained in:
Jan Nieuwenhuizen 2017-08-05 12:39:36 +02:00
parent 3f4cc96a7b
commit 31c69b8b00
2 changed files with 6 additions and 4 deletions

View file

@ -570,7 +570,7 @@
(let* ((info ((expr->accu* info) o)) (let* ((info ((expr->accu* info) o))
(type0 (ident->type info struct0)) (type0 (ident->type info struct0))
(type1 (field-type info type0 field0)) (type1 (field-type info type0 field0))
(struct? (and (pair? type1) (equal? (car type1) "tag"))) (struct? (memq (type:type (ast-type->type info type0)) '(struct union)))
(ptr (field-pointer info type0 field0)) (ptr (field-pointer info type0 field0))
(size (ast-type->size info type1))) (size (ast-type->size info type1)))
(if (= ptr -3) info (if (= ptr -3) info
@ -583,7 +583,7 @@
(let* ((info ((expr->accu* info) o)) (let* ((info ((expr->accu* info) o))
(type0 (ident->type info struct0)) (type0 (ident->type info struct0))
(type1 (field-type info type0 field0)) (type1 (field-type info type0 field0))
(struct? (and (pair? type1) (equal? (car type1) "tag"))) (struct? (memq (type:type (ast-type->type info type0)) '(struct union)))
(ptr (field-pointer info type0 field0)) (ptr (field-pointer info type0 field0))
(size (ast-type->size info type1))) (size (ast-type->size info type1)))
(append-text info (wrap-as (append (if (and (= ptr -2) struct?) (i386:mem->accu) '()) (append-text info (wrap-as (append (if (and (= ptr -2) struct?) (i386:mem->accu) '())

View file

@ -46,14 +46,16 @@ add (void *ptab, int *nb_ptr, void *data)
*nb_ptr = nb; *nb_ptr = nb;
} }
struct file { typedef struct file {
char name[4]; char name[4];
}; } file_struct;
struct state { struct state {
int bla;
char **paths; char **paths;
int path_count; int path_count;
struct file **files; struct file **files;
//file_struct **files;
int file_count; int file_count;
}; };