From b42ecbd9286e3f9108c72b5d3d1f99a34a122ffa Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 11 May 2018 18:26:01 +0200 Subject: [PATCH] mescc: Tinycc support: Array typedefs. --- module/language/c99/compiler.mes | 7 +++++++ scaffold/tests/t.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 33a7a56c..86896bf0 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -1722,6 +1722,13 @@ (let* ((info (type->info type name info)) (type (ast->type type info))) (clone info #:types (acons name type (.types info))))) + ;; FIXME: recursive types, pointer, array + (((decl-spec-list (stor-spec (typedef)) (type-spec ,type)) (init-declr-list (init-declr (array-of (ident ,name) ,count)))) + (let* ((info (type->info type name info)) + (type (ast->type type info)) + (count (expr->number info count)) + (type (make-c-array type count))) + (clone info #:types (acons name type (.types info))))) (((decl-spec-list (stor-spec (,store)) (type-spec ,type)) (init-declr-list . ,inits)) (let* ((type (ast->type type info)) (function (.function info))) diff --git a/scaffold/tests/t.c b/scaffold/tests/t.c index a102f602..8fe749ce 100644 --- a/scaffold/tests/t.c +++ b/scaffold/tests/t.c @@ -43,6 +43,9 @@ struct anion {union {int foo; int bar;}; union {int baz; int bla;};}; struct here {int and;} there; +typedef int int_array_t[1]; +int_array_t bar; + int test (struct foo* p) {