]> git.saurik.com Git - cycript.git/blobdiff - sig/ffi_type.cpp
Update the copyright year now that 2016 has begun.
[cycript.git] / sig / ffi_type.cpp
index e114db876e18f21abac0a377ec04b1a7313c8574..5d31b0f70b757e941f1b53239fa928bb911f1208 100644 (file)
@@ -1,5 +1,5 @@
-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015  Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016  Jay Freeman (saurik)
 */
 
 /* GNU Affero General Public License, Version 3 {{{ */
 */
 
 /* GNU Affero General Public License, Version 3 {{{ */
@@ -158,10 +158,17 @@ ffi_type *Aggregate::GetFFI(CYPool &pool) const {
     ffi->alignment = 0;
     ffi->type = FFI_TYPE_STRUCT;
 
     ffi->alignment = 0;
     ffi->type = FFI_TYPE_STRUCT;
 
-    ffi->elements = new(pool) ffi_type *[signature.count + 1];
-    for (size_t index(0); index != signature.count; ++index)
-        ffi->elements[index] = signature.elements[index].type->GetFFI(pool);
-    ffi->elements[signature.count] = NULL;
+    if (signature.count == 0) {
+        // https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01286.html
+        ffi->elements = new(pool) ffi_type *[2];
+        ffi->elements[0] = &ffi_type_void;
+        ffi->elements[1] = NULL;
+    } else {
+        ffi->elements = new(pool) ffi_type *[signature.count + 1];
+        for (size_t index(0); index != signature.count; ++index)
+            ffi->elements[index] = signature.elements[index].type->GetFFI(pool);
+        ffi->elements[signature.count] = NULL;
+    }
 
     return ffi;
 }
 
     return ffi;
 }