promote a lone arithmetic operand
One operand was joined with nothing and came back as it was, so (- c) over a char was a char where C makes it an int.
This commit is contained in:
@@ -689,6 +689,13 @@ whitespace aside, THEN?"
|
||||
"ptrdiff_t d = p - xs"))
|
||||
(test-assert "a number from a pointer is still a pointer"
|
||||
(emits? (in-fn "(var p (* int) 0) (var r _ (- p 1))") "int * r = p - 1"))
|
||||
;; one operand was a join with nothing, which left it unpromoted
|
||||
(test-assert "a negation promotes its operand"
|
||||
(emits? (in-fn "(var c char 1) (var n _ (- c))") "int n = -c"))
|
||||
(test-assert "so does a unary plus"
|
||||
(emits? (in-fn "(var h short 1) (var n _ (+ h))") "int n = +h"))
|
||||
(test-assert "and leaves a wide one as it is"
|
||||
(emits? (in-fn "(var l long 1) (var n _ (- l))") "long n = -l"))
|
||||
;; a compound literal carries its own type, where a brace
|
||||
;; initializer has none and takes one from its context
|
||||
(test-assert "a compound literal answers a bare wildcard"
|
||||
|
||||
Reference in New Issue
Block a user