diff options
author | Armin Rigo <arigo@tunes.org> | 2020-10-29 10:32:25 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-10-29 10:32:25 +0100 |
commit | 91f92834a124383fc07e5633d242772bbef9b29e (patch) | |
tree | 466d3cd9cb11376b3243b1a09a9f41a6aee9128f /testing | |
parent | c6c5b0d848b02aaf8d3e43d8cc191f53a1e9664e (diff) | |
download | cffi-91f92834a124383fc07e5633d242772bbef9b29e.tar.gz |
Issue #478
Fix a case of nested anonymous struct/unions when recompiling to Python
Diffstat (limited to 'testing')
-rw-r--r-- | testing/cffi1/test_re_python.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/testing/cffi1/test_re_python.py b/testing/cffi1/test_re_python.py index dce4f40..2ae0dd1 100644 --- a/testing/cffi1/test_re_python.py +++ b/testing/cffi1/test_re_python.py @@ -74,6 +74,7 @@ def setup_module(mod): int strlen(const char *); struct with_union { union { int a; char b; }; }; union with_struct { struct { int a; char b; }; }; + struct with_struct_with_union { struct { union { int x; }; } cp; }; struct NVGcolor { union { float rgba[4]; struct { float r,g,b,a; }; }; }; typedef struct selfref { struct selfref *next; } *selfref_ptr_t; """) @@ -248,6 +249,10 @@ def test_anonymous_union_inside_struct(): assert ffi.offsetof("union with_struct", "b") == INT assert ffi.sizeof("union with_struct") >= INT + 1 # + assert ffi.sizeof("struct with_struct_with_union") == INT + p = ffi.new("struct with_struct_with_union *") + assert p.cp.x == 0 + # FLOAT = ffi.sizeof("float") assert ffi.sizeof("struct NVGcolor") == FLOAT * 4 assert ffi.offsetof("struct NVGcolor", "rgba") == 0 |