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 d393c62278
commit a1ba367eae
2 changed files with 30 additions and 6 deletions

View File

@@ -848,6 +848,18 @@ whitespace aside, THEN?"
(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;")))
;; c-struct/aux wrote the tag and the first `*' after it, and
;; dropped the rest of the chain
(test-group "a pointer chain to a struct"