self-referential c record imports

This commit is contained in:
2026-06-25 07:43:43 +02:00
parent 4cb0ad7f25
commit 9d1130b359
8 changed files with 65 additions and 8 deletions
+14
View File
@@ -1972,6 +1972,20 @@ by_value_c_records_and_unions_compile_and_link :: proc(t: ^testing.T) {
testing.expect_value(t, state.exit_code, 1)
}
@(test)
self_referential_c_records_import_and_compile :: proc(t: ^testing.T) {
// `struct Node { struct Node *next; int value; }`: the importer must not recurse
// forever populating the self-referential record, and the checker must accept the
// self-referential `?*mut Node` field as C-layout-compatible.
output := "/tmp/brolang-test-recursive"
defer _ = os.remove(output)
c_options := cimport.Options{include_paths=[]string{"examples/interop/recursive/include"}}
status := compiler_core.compile_package("examples/interop/recursive/app", output, nil, target.DEFAULT, c_options)
testing.expect_value(t, status, 0)
state := run_executable(output)
testing.expect_value(t, state.exit_code, 0)
}
@(test)
unsupported_c_header_members_diagnose_only_when_referenced :: proc(t: ^testing.T) {
output := "/tmp/brolang-test-header-unsupported"