aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-reflect-call.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-11-19 02:30:03 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-11-19 02:30:03 +0000
commit41674b9fe4c0beb00ac29c32a2085fa670e863a9 (patch)
tree16f6d5875810d941d00dcc7096e6e77ae76ce1bf /libgo/runtime/go-reflect-call.c
parent9d5eec2da6a8ce4e457cb25be2c2a1e60a49f8fb (diff)
downloadgcc-41674b9fe4c0beb00ac29c32a2085fa670e863a9.zip
gcc-41674b9fe4c0beb00ac29c32a2085fa670e863a9.tar.gz
gcc-41674b9fe4c0beb00ac29c32a2085fa670e863a9.tar.bz2
reflect: Handle calls to functions that take or return empty structs
Fixes issue 6761 This simple change seems to work fine, slightly to my surprise. This includes the tests I submitted to the main Go repository at https://codereview.appspot.com/26570046 From-SVN: r205001
Diffstat (limited to 'libgo/runtime/go-reflect-call.c')
-rw-r--r--libgo/runtime/go-reflect-call.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c
index 0fed68a..07b99d7 100644
--- a/libgo/runtime/go-reflect-call.c
+++ b/libgo/runtime/go-reflect-call.c
@@ -98,9 +98,12 @@ go_struct_to_ffi (const struct __go_struct_type *descriptor)
const struct __go_struct_field *fields;
int i;
+ field_count = descriptor->__fields.__count;
+ if (field_count == 0) {
+ return &ffi_type_void;
+ }
ret = (ffi_type *) __go_alloc (sizeof (ffi_type));
ret->type = FFI_TYPE_STRUCT;
- field_count = descriptor->__fields.__count;
fields = (const struct __go_struct_field *) descriptor->__fields.__values;
ret->elements = (ffi_type **) __go_alloc ((field_count + 1)
* sizeof (ffi_type *));