keep an array literal a global pointer is set to
At file scope every compound literal was cut down to its braces, right for a value and not for an array a pointer points at: the address of a static object is a constant, and its braces alone the pointer's own.
This commit is contained in:
@@ -1126,7 +1126,24 @@ whitespace aside, THEN?"
|
||||
(test-assert "ahead of it"
|
||||
(let ((c (sex->c "(var f (fn ((x int)) int) (lambda ((x int)) int (return x)))")))
|
||||
(< (string-contains c "static int λ0_f (int x)")
|
||||
(string-contains c "(*f)(int) = λ0_f")))))
|
||||
(string-contains c "(*f)(int) = λ0_f"))))
|
||||
;; every compound literal lost its type at file scope, which is right
|
||||
;; for a value and not for an array a pointer is set to: that is the
|
||||
;; address of a static object, and its braces alone the pointer's own
|
||||
(test-assert "an array a pointer is set to keeps its type"
|
||||
(emits? "(var gp (* int) #([int 3] : 1 2 3))" "int * gp = (int [3]){1, 2, 3}"))
|
||||
(test-assert "in a field named for it"
|
||||
(emits? (string-append "(struct h ((p (* int)) (n int)))"
|
||||
"(var g (struct h) #(.p #([int 2] : 1 2) .n 3))")
|
||||
"{.p = (int [2]){1, 2}, .n = 3}"))
|
||||
(test-assert "or one in its place"
|
||||
(emits? (string-append "(struct h ((n int) (p (* int))))"
|
||||
"(var g (struct h) #((struct h) : 3 #([int 2] : 1 2)))")
|
||||
"{3, (int [2]){1, 2}}"))
|
||||
(test-assert "while a value is still its braces"
|
||||
(emits? (string-append "(struct pt ((x int))) (struct h2 ((a (struct pt))))"
|
||||
"(var g (struct h2) #(#((struct pt) : 1)))")
|
||||
"h2 g = {{1}}")))
|
||||
|
||||
;; Toplevel forms used to be separated by a blank line unconditionally,
|
||||
;; which spread a block of adjacent typedefs over twice the lines its
|
||||
|
||||
Reference in New Issue
Block a user