From 91f92834a124383fc07e5633d242772bbef9b29e Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Thu, 29 Oct 2020 10:32:25 +0100 Subject: Issue #478 Fix a case of nested anonymous struct/unions when recompiling to Python --- testing/cffi1/test_re_python.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'testing') 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 -- cgit v1.2.1