1
0
forked from alex-eg/sex

start a global from braces, not a compound literal

A compound literal is no constant in C11, so a global built by a
constructor or a typed literal failed under -pedantic-errors; gcc says
so, clang lets it pass.
This commit is contained in:
2026-10-15 11:20:53 +03:00
parent 6cda0873c6
commit 913af0b463
3 changed files with 27 additions and 6 deletions

View File

@@ -203,7 +203,11 @@
(not (emits? "(pub sum t ((a ((x int)))))(fn f () t (return (t/a 1)))"
"t tːa (")))
(test-assert "so it is a constant at file scope"
(emits? "(sum t ((a ((x int)))))(var g t (t/a 1))" "static t g = (t){"))
(emits? "(sum t ((a ((x int)))))(var g t (t/a 1))"
"static t g = {.tag = tǂa, .u = {.a = {1}}};"))
(test-assert "as is any literal a global starts from"
(emits? "(record point ((x int) (y int)))(var g point #(point : 1 2))"
"static point g = {1, 2};"))
(test-assert "and an lvalue a method can take the address of"
(emits? (string-append
"(sum t ((a ((x int)))))"