aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-31 20:15:47 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-31 20:15:47 -0700
commit954afe5d9a5ae634f7db22641ebac6e755cdaba7 (patch)
tree21183728874263dd440cb46dcb563b418f3cefbe /src/analyze.cpp
parentf20d0665bb9bfc3079028df59b754b028e8b83ec (diff)
downloadzig-954afe5d9a5ae634f7db22641ebac6e755cdaba7.tar.gz
zig-954afe5d9a5ae634f7db22641ebac6e755cdaba7.zip
fix C interaction with maybe function pointers
See #88
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp8
1 files changed, 6 insertions, 2 deletions
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);
}