From e77e56c5b01008f926d854bacf0635d367fd3277 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 19 Nov 2017 16:46:43 +0100 Subject: [PATCH] mescc: Grok char *const foo[]; * module/language/c99/compiler.mes (ast-strip-const): Grok char *const argv[]; --- module/language/c99/compiler.mes | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 4fe3019a..ab4cff55 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -90,9 +90,17 @@ (define (ast-strip-const o) (pmatch o ((type-qual ,qual) (if (equal? qual "const") #f o)) + ((pointer (type-qual-list (type-qual ,qual)) . ,rest) + (if (equal? qual "const") `(pointer ,@rest) o)) + ((decl-spec-list (type-qual ,qual)) + (if (equal? qual "const") #f + `(decl-spec-list (type-qual ,qual)))) ((decl-spec-list (type-qual ,qual) . ,rest) (if (equal? qual "const") `(decl-spec-list ,@rest) `(decl-spec-list (type-qual ,qual) ,@(map ast-strip-const rest)))) + ((decl-spec-list (type-qual-list (type-qual ,qual)) . ,rest) + (if (equal? qual "const") `(decl-spec-list ,@rest) + `(decl-spec-list (type-qual-list (type-qual ,qual)) ,@(map ast-strip-const rest)))) ((,h . ,t) (if (list? o) (filter-map ast-strip-const o) (cons (ast-strip-const h) (ast-strip-const t)))) (_ o))) @@ -115,6 +123,8 @@ ((param-decl _ (param-declr (ptr-declr (pointer) (array-of (ident ,name))))) name) ((param-decl _ (param-declr (ptr-declr (pointer (pointer)) (ident ,name)))) name) ((param-decl _ (param-declr (ptr-declr (pointer (pointer (pointer))) (ident ,name)))) name) + ((param-decl _ (param-declr (ptr-declr (pointer (decl-spec-list) (pointer)) (ident ,name)))) name) + ((param-decl _ (param-declr (ptr-declr (pointer (decl-spec-list)) (array-of (ident ,name))))) name) ((param-decl _ (param-declr (ftn-declr (scope (ptr-declr (pointer) (ident ,name))) (param-list . ,params)))) name) (_ (format (current-error-port) "SKIP: .name =~a\n" o))))