From 954afe5d9a5ae634f7db22641ebac6e755cdaba7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 31 Jan 2016 20:15:47 -0700 Subject: fix C interaction with maybe function pointers See #88 --- src/analyze.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index f574c8d4b4..756f12251e 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -214,9 +214,12 @@ TypeTableEntry *get_maybe_type(CodeGen *g, TypeTableEntry *child_type) { buf_resize(&entry->name, 0); buf_appendf(&entry->name, "?%s", buf_ptr(&child_type->name)); - if (child_type->id == TypeTableEntryIdPointer) { + if (child_type->id == TypeTableEntryIdPointer || + child_type->id == TypeTableEntryIdFn) + { // this is an optimization but also is necessary for calling C // functions where all pointers are maybe pointers + // function types are technically pointers entry->size_in_bits = child_type->size_in_bits; entry->align_in_bits = child_type->align_in_bits; entry->type_ref = child_type->type_ref; @@ -5384,7 +5387,8 @@ bool handle_is_ptr(TypeTableEntry *type_entry) { case TypeTableEntryIdEnum: return type_entry->data.enumeration.gen_field_count != 0; case TypeTableEntryIdMaybe: - return type_entry->data.maybe.child_type->id != TypeTableEntryIdPointer; + return type_entry->data.maybe.child_type->id != TypeTableEntryIdPointer && + type_entry->data.maybe.child_type->id != TypeTableEntryIdFn; case TypeTableEntryIdTypeDecl: return handle_is_ptr(type_entry->data.type_decl.canonical_type); } -- cgit v1.2.3