From dda32c7569ae6b070862d122d2b47114267e1d40 Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Mon, 11 Mar 2019 10:27:38 +0100 Subject: Fix (corner case, hard to test) --- c/_cffi_backend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'c') diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c index e163b1d..ac0bc2a 100644 --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -4973,14 +4973,18 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args) goto error; } } - else if (ftype->ct_flags & CT_WITH_VAR_ARRAY) { + else if (ftype->ct_flags & (CT_STRUCT|CT_UNION)) { + if (force_lazy_struct(ftype) < 0) /* for CT_WITH_VAR_ARRAY */ + return NULL; + /* GCC (or maybe C99) accepts var-sized struct fields that are not the last field of a larger struct. That's why there is no check here for "last field": we propagate the flag CT_WITH_VAR_ARRAY to any struct that contains either an open- ended array or another struct that recursively contains an open-ended array. */ - ct->ct_flags |= CT_WITH_VAR_ARRAY; + if (ftype->ct_flags & CT_WITH_VAR_ARRAY) + ct->ct_flags |= CT_WITH_VAR_ARRAY; } if (is_union) -- cgit v1.2.1