1
0
forked from alex-eg/sex

keep an aggregate written in place behind a pointer

A type was flattened word by word, a struct's body included, so
(* (struct ((c int)))) came out struct c{ int; } *.
This commit is contained in:
2026-10-17 17:35:48 +03:00
parent 32515c0eb8
commit 1b59848b42
2 changed files with 30 additions and 6 deletions

View File

@@ -790,6 +790,18 @@
(test-assert "and negation beside a binary operator"
(emits? (in-fn "(var n int (+ (- a) b))") "-a + b")))
;; A type was flattened word by word, a struct written out in it
;; included: (* (struct ((c int)))) came out `struct c{ int; } *'
(test-group "a pointer to an aggregate written in place"
(test-assert "keeps its fields"
(followed-by? "(struct h ((b (* (struct ((c int)))))))" "int c;" "} * b;"))
(test-assert "a pointer among them as well"
(emits? "(struct h ((b (* (struct ((p (* int)) (n int)))))))" "int * p;"))
(test-assert "and a qualifier before it"
(emits? "(struct h ((e (* const (union ((u int) (v float)))))))" "const union{"))
(test-assert "behind as many stars as are written"
(emits? "(struct h ((f (* * (struct ((c int)))))))" "} * * f;")))
;; Operands past what an operator takes were written as they came:
;; (< a b c) as C's own chain, which compares a boolean with c
(test-group "operator arity"