v4/lib: add regression test for nested union with pointer member (issue #47)
Summary
Add regression test for issue #47 (closed): nested union with pointer member.
This test exercises the scenario that was broken before commit d32226db:
nested unions whose active member is a struct containing a pointer, with
a larger alternative member. The old arrayElemOff heuristic produced
_ [-16]byte (invalid Go); the fix (pre := lcaOff - off0) computes
the correct padding.
What's included
testdata/issue47.c— standalone C test case (also picked up byTestOtherin the root package)v4/lib/issue47_test.go— Go regression test that:- Compiles the C source with
hostCCand records the expected output - Transpiles it with ccgo (
NewTask) - Builds the generated Go with
go build - Runs both binaries and compares their output
- Compiles the C source with
Test results
=== RUN TestIssue47Regression
issue47_test.go:101: ccgo OK
issue47_test.go:134: output: a0=1 a1=3 PASS
--- PASS: TestIssue47Regression (5.31s)TestGoAlign and TestSep also pass with no regressions.
Refs: #47 (closed)