fix (. (* p) x) expanding to *(p).x
Was an fmt-c-writer bug: unary-op must parenthize itself, and not it's arg
This commit is contained in:
@@ -1015,9 +1015,24 @@
|
||||
(cat nl (make-space (+ 2 (fmt-col st))) str " "))
|
||||
st))))))))))
|
||||
|
||||
;; `-' arrives as the symbol binary minus uses, and so with binary
|
||||
;; precedence: `(+ (- b) b)' asked under that spelling comes out
|
||||
;; `(-b) + b'.
|
||||
(define (unary-operator op)
|
||||
(case op
|
||||
((-) 'unary-)
|
||||
((+) 'unary+)
|
||||
((*) 'unary-*)
|
||||
((&) 'unary-&)
|
||||
(else op)))
|
||||
|
||||
;; Parenthesises the whole expression rather than the operand: the
|
||||
;; other way round, `(. (* p) x)' came out `*(p).x', which C reads as
|
||||
;; `*(p.x)'.
|
||||
(define (c-unary-op op x)
|
||||
(c-wrap-stmt
|
||||
(cat (display-to-string op) (c-maybe-paren op (c-expr x)))))
|
||||
(c-maybe-paren (unary-operator op)
|
||||
(cat (display-to-string op) (c-expr x)))))
|
||||
|
||||
;; some convenience definitions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user