Issue #455 - Avoid generating C code containing unused variables

This commit is contained in:
Justin Ethier 2021-04-12 14:19:13 -04:00
parent 26cd116cb8
commit 1187d7fab1
2 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,11 @@
# Changelog
## TBD
Bug Fixes
- Avoid generating C code containing unused variables. In addition to generating better code this also prevents the C compiler from raising associated warnings.
## 0.28.0 - April 8, 2021
Features

View file

@ -1299,10 +1299,15 @@
(let ((exps (foldr
(lambda (expr acc)
;; Join expressions; based on c:append
(let ((cp1 (if (ref? expr)
;; Ignore lone ref to avoid C warning
(c:code/vars "" '())
(c-compile-exp expr append-preamble cont ast-id trace cps?)))
(let ((cp1 (cond
((ref? expr)
;; Ignore lone ref to avoid C warning
(c:code/vars "" '()))
((tagged-list? '%closure expr)
;; Discard unused func and avoid C warning
(c:code/vars "" '()))
(else
(c-compile-exp expr append-preamble cont ast-id trace cps?))))
(cp2 acc))
(c:code/vars
(let ((cp1-body (c:body cp1)))