From 9783fe1a7b1090b0e2520484636e3020158758c7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 29 Jun 2017 04:52:37 -0700 Subject: ffi: reject bitfields as arguments or return values. * ffi.c (ffi_make_call_desc): Throw error if argument or return value is a bitfield. --- ffi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ffi.c') diff --git a/ffi.c b/ffi.c index 1c3b928c..4a2db26d 100644 --- a/ffi.c +++ b/ffi.c @@ -4103,6 +4103,9 @@ val ffi_make_call_desc(val ntotal, val nfixed, val rettype, val argtypes) if (tft->size == 0) uw_throwf(error_s, lit("~a: can't pass type ~s by value"), self, type, nao); + if (bitfield_syntax_p(tft->syntax)) + uw_throwf(error_s, lit("~a: can't pass bitfield as argument"), + self, nao); args[i] = tft->ft; } @@ -4111,6 +4114,9 @@ val ffi_make_call_desc(val ntotal, val nfixed, val rettype, val argtypes) if (tft->size == 0 && tft->ft != &ffi_type_void) uw_throwf(error_s, lit("~a: can't return type ~s by value"), self, rettype, nao); + if (bitfield_syntax_p(tft->syntax)) + uw_throwf(error_s, lit("~a: can't return bitfield from function"), + self, nao); } if (tfcd->variadic) -- cgit v1.2.3