mescc: Skip attributes on function definitions.

* module/mescc/preprocess.scm (ast-strip-attributes): New procedure.
(c99-input->ast): Use it.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-12-13 09:41:38 +01:00
parent 5eaf1c14ef
commit 1e102e1d46
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 12 additions and 1 deletions

View File

@ -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)))