From 1e102e1d467ffa211baba44704a0e64c5c6ca2f4 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sun, 13 Dec 2020 09:41:38 +0100 Subject: [PATCH] mescc: Skip attributes on function definitions. * module/mescc/preprocess.scm (ast-strip-attributes): New procedure. (c99-input->ast): Use it. --- module/mescc/preprocess.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/module/mescc/preprocess.scm b/module/mescc/preprocess.scm index d4e9a6c9..c8bfa511 100644 --- a/module/mescc/preprocess.scm +++ b/module/mescc/preprocess.scm @@ -112,7 +112,10 @@ (define* (c99-input->ast #:key (prefix "") (defines '()) (includes '()) (arch "") verbose?) (when verbose? (stderr "parsing: input\n")) - ((compose ast-strip-const ast-strip-comment) (c99-input->full-ast #:prefix prefix #:defines defines #:includes includes #:arch arch #:verbose? verbose?))) + ((compose ast-strip-attributes + ast-strip-const + ast-strip-comment) + (c99-input->full-ast #:prefix prefix #:defines defines #:includes includes #:arch arch #:verbose? verbose?))) (define (ast-strip-comment o) (pmatch o @@ -142,3 +145,11 @@ ((,h . ,t) (if (list? o) (filter-map ast-strip-const o) (cons (ast-strip-const h) (ast-strip-const t)))) (_ o))) + +(define (ast-strip-attributes o) + (pmatch o + ((decl-spec-list (@ (attributes . ,attributes)) . ,rest) + `(decl-spec-list ,@rest)) + ((,h . ,t) (if (list? o) (filter-map ast-strip-attributes o) + (cons (ast-strip-attributes h) (ast-strip-attributes t)))) + (_ o)))