aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index d479f30e60..e3391c450a 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -393,7 +393,10 @@ pub const DeclGen = struct {
val: Value,
decl_index: Decl.Index,
) error{ OutOfMemory, AnalysisFail }!void {
- if (ty.isPtrAtRuntime() and !ty.elemType2().isFnOrHasRuntimeBits()) {
+ const decl = dg.module.declPtr(decl_index);
+ assert(decl.has_tv);
+
+ if (ty.isPtrAtRuntime() and !decl.ty.isFnOrHasRuntimeBits()) {
return dg.writeCValue(writer, CValue{ .undefined_ptr = ty });
}
@@ -409,8 +412,6 @@ pub const DeclGen = struct {
return;
}
- const decl = dg.module.declPtr(decl_index);
- assert(decl.has_tv);
// We shouldn't cast C function pointers as this is UB (when you call
// them). The analysis until now should ensure that the C function
// pointers are compatible. If they are not, then there is a bug