From 8cc406c9ffc2ef6d95fcbf9ada5ab4ba5a5a51c8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 11 May 2018 18:36:35 +0200 Subject: [PATCH] mescc: Tinycc support: Pointer typedefs. --- module/language/c99/compiler.mes | 6 ++++++ scaffold/tests/t.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 86896bf0..9f1d89a6 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -1729,6 +1729,12 @@ (count (expr->number info count)) (type (make-c-array type count))) (clone info #:types (acons name type (.types info))))) + (((decl-spec-list (stor-spec (typedef)) (type-spec ,type)) (init-declr-list (init-declr (ptr-declr ,pointer (ident ,name))))) + (let* ((info (type->info type name info)) + (type (ast->type type info)) + (rank (pointer->rank pointer)) + (type (rank+= type rank))) + (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 8fe749ce..ff3ec8ee 100644 --- a/scaffold/tests/t.c +++ b/scaffold/tests/t.c @@ -46,6 +46,9 @@ struct here {int and;} there; typedef int int_array_t[1]; int_array_t bar; +typedef struct foo *foo_pointer_t; +foo_pointer_t foep; + int test (struct foo* p) {