forked from alex-eg/sex
keep what follows the star of a pointer to a tagged type
fmt-c wrote (const * struct what) as struct what*, and (* * struct what) as struct what*, a pointer short; a pointer to an enum crashed it, the star taken for the enum's values.
This commit is contained in:
@@ -855,6 +855,22 @@
|
||||
(< (string-contains c "static int λ0_f (int x)")
|
||||
(string-contains c "(*f)(int) = λ0_f")))))
|
||||
|
||||
;; fmt-c kept the first star after a tag and dropped what followed it,
|
||||
;; and took an enum's star for its list of values
|
||||
(test-group "pointers to tagged types"
|
||||
(test-assert "a const pointer to a struct stays const"
|
||||
(emits? "(var q (const * struct what))" "struct what* const q;"))
|
||||
(test-assert "and one in an array"
|
||||
(emits? "(var a [const * struct what 4])" "struct what* const a[4];"))
|
||||
(test-assert "a pointer to a pointer keeps both stars"
|
||||
(emits? "(var pp (* * struct what))" "struct what* * pp;"))
|
||||
(test-assert "so does a union's"
|
||||
(emits? "(var u (const * union val))" "union val* const u;"))
|
||||
(test-assert "a pointer to an enum is a pointer"
|
||||
(emits? "(enum mood (glad sad)) (var e (* enum mood))" "enum mood* e;"))
|
||||
(test-assert "and a const one"
|
||||
(emits? "(enum mood (glad sad)) (var f (const * enum mood))" "enum mood* const f;")))
|
||||
|
||||
;; Toplevel forms used to be separated by a blank line unconditionally,
|
||||
;; which spread a block of adjacent typedefs over twice the lines its
|
||||
;; author wrote
|
||||
|
||||
Reference in New Issue
Block a user