aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-23 12:21:47 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-23 12:21:47 -0700
commit55b28ab0301237b8c9e39db4160036a42544f836 (patch)
tree83ff05b5b2715b90ee1167758d609574f8bff6ca /src/analyze.cpp
parentda406cb11287e2961ad5aaa6ca857efd57fb9d03 (diff)
downloadzig-55b28ab0301237b8c9e39db4160036a42544f836.tar.gz
zig-55b28ab0301237b8c9e39db4160036a42544f836.zip
fix returning empty struct from function
closes #142
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 572fa4df9c..b0efb7bbc1 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -623,7 +623,6 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
buf_appendf(&fn_type->name, " -> %s", buf_ptr(&fn_type_id->return_type->name));
}
-
// next, loop over the parameters again and compute debug information
// and codegen information
bool first_arg_return = handle_is_ptr(fn_type_id->return_type);
@@ -634,15 +633,15 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
param_di_types[0] = fn_type_id->return_type->di_type;
int gen_param_index = 0;
TypeTableEntry *gen_return_type;
- if (first_arg_return) {
+ if (!type_has_bits(fn_type_id->return_type)) {
+ gen_return_type = g->builtin_types.entry_void;
+ } else if (first_arg_return) {
TypeTableEntry *gen_type = get_pointer_to_type(g, fn_type_id->return_type, false);
gen_param_types[gen_param_index] = gen_type->type_ref;
gen_param_index += 1;
// after the gen_param_index += 1 because 0 is the return type
param_di_types[gen_param_index] = gen_type->di_type;
gen_return_type = g->builtin_types.entry_void;
- } else if (!type_has_bits(fn_type_id->return_type)) {
- gen_return_type = g->builtin_types.entry_void;
} else {
gen_return_type = fn_type_id->return_type;
}