aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-11 16:04:04 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-11 16:04:04 -0400
commitb3a4ec1bd209c022445b6f70385b3f88517e72f9 (patch)
tree7e94fb3e78bc209cc97ed48797bcde338beb6c07 /src/ir.cpp
parente1d14e73b5f9c7a8d1a92ccd36cb689d625faf57 (diff)
downloadzig-b3a4ec1bd209c022445b6f70385b3f88517e72f9.tar.gz
zig-b3a4ec1bd209c022445b6f70385b3f88517e72f9.zip
fix returning scalar values
```zig export fn entry1() i32 { return bar(); } ``` ```llvm define i32 @entry1() #2 !dbg !35 { Entry: %0 = call fastcc i32 @bar(), !dbg !39 ret i32 %0, !dbg !41 } ```
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index df7a593601..b3d5109e93 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14866,7 +14866,11 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
}
case ResultLocIdReturn: {
bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime;
- if (is_comptime) return nullptr;
+ if (is_comptime)
+ return nullptr;
+ if (!type_has_bits(ira->explicit_return_type) || !handle_is_ptr(ira->explicit_return_type))
+ return nullptr;
+
ZigType *ptr_return_type = get_pointer_to_type(ira->codegen, ira->explicit_return_type, false);
result_loc->written = true;
result_loc->resolved_loc = ir_build_return_ptr(ira, result_loc->source_instruction, ptr_return_type);