diff options
| author | Armin Rigo <arigo@tunes.org> | 2018-01-31 21:39:19 +0100 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2018-01-31 21:39:19 +0100 |
| commit | 0c20cb6f04a8bbae352bf71e4cab149da77f5918 (patch) | |
| tree | 6569799e9f46315c0479d95cc6161bc1f7fbf1be /testing/cffi1/test_re_python.py | |
| parent | 6d08968ac72990cefcb33c9efb58e68f320c6424 (diff) | |
| download | cffi-0c20cb6f04a8bbae352bf71e4cab149da77f5918.tar.gz | |
Issue #357: fix the out-of-line ABI mode when we see structs
containing anonymous unions or vice-versa
Diffstat (limited to 'testing/cffi1/test_re_python.py')
| -rw-r--r-- | testing/cffi1/test_re_python.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/testing/cffi1/test_re_python.py b/testing/cffi1/test_re_python.py index 5de532d..6ae6e12 100644 --- a/testing/cffi1/test_re_python.py +++ b/testing/cffi1/test_re_python.py @@ -55,6 +55,8 @@ def setup_module(mod): typedef struct bar_s { int x; signed char a[]; } bar_t; enum foo_e { AA, BB, CC }; int strlen(const char *); + struct with_union { union { int a; char b; }; }; + union with_struct { struct { int a; char b; }; }; """) ffi.set_source('re_python_pysrc', None) ffi.emit_python_code(str(tmpdir.join('re_python_pysrc.py'))) @@ -212,3 +214,14 @@ def test_partial_enum(): ffi.set_source('test_partial_enum', None) py.test.raises(VerificationMissing, ffi.emit_python_code, str(tmpdir.join('test_partial_enum.py'))) + +def test_anonymous_union_inside_struct(): + # based on issue #357 + from re_python_pysrc import ffi + assert ffi.offsetof("struct with_union", "a") == 0 + assert ffi.offsetof("struct with_union", "b") == 0 + assert ffi.sizeof("struct with_union") == ffi.sizeof("int") + # + assert ffi.offsetof("union with_struct", "a") == 0 + assert ffi.offsetof("union with_struct", "b") == 4 + assert ffi.sizeof("union with_struct") >= ffi.sizeof("int") + 1 |
