IR: pass genericMallocFree test
parent
110a6f39ca
commit
3ef6663b72
|
@ -2839,7 +2839,6 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
|
|||
case TypeTableEntryIdUndefLit:
|
||||
case TypeTableEntryIdNullLit:
|
||||
case TypeTableEntryIdMetaType:
|
||||
case TypeTableEntryIdVoid:
|
||||
case TypeTableEntryIdNamespace:
|
||||
case TypeTableEntryIdBlock:
|
||||
case TypeTableEntryIdBoundFn:
|
||||
|
@ -2857,6 +2856,7 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
|
|||
case TypeTableEntryIdFloat:
|
||||
case TypeTableEntryIdPointer:
|
||||
case TypeTableEntryIdEnumTag:
|
||||
case TypeTableEntryIdVoid:
|
||||
return false;
|
||||
}
|
||||
zig_unreachable();
|
||||
|
|
|
@ -6350,13 +6350,13 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
|
|||
if (casted_arg->value.type->id == TypeTableEntryIdInvalid)
|
||||
return false;
|
||||
|
||||
ConstExprValue *first_arg_val = ir_resolve_const(ira, casted_arg, UndefBad);
|
||||
if (!first_arg_val)
|
||||
ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefBad);
|
||||
if (!arg_val)
|
||||
return false;
|
||||
|
||||
Buf *param_name = param_decl_node->data.param_decl.name;
|
||||
VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,
|
||||
*exec_scope, param_name, true, first_arg_val);
|
||||
*exec_scope, param_name, true, arg_val);
|
||||
*exec_scope = var->child_scope;
|
||||
*next_proto_i += 1;
|
||||
|
||||
|
|
|
@ -278,6 +278,20 @@ fn explicitCastMaybePointers() {
|
|||
const b: ?&f32 = (?&f32)(a);
|
||||
}
|
||||
|
||||
fn genericMallocFree() {
|
||||
@setFnTest(this);
|
||||
|
||||
const a = %%memAlloc(u8, 10);
|
||||
memFree(u8, a);
|
||||
}
|
||||
const some_mem : [100]u8 = undefined;
|
||||
fn memAlloc(inline T: type, n: usize) -> %[]T {
|
||||
return (&T)(&some_mem[0])[0...n];
|
||||
}
|
||||
fn memFree(inline T: type, mem: []T) { }
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO import from std.str
|
||||
pub fn memeql(a: []const u8, b: []const u8) -> bool {
|
||||
|
|
|
@ -4,28 +4,6 @@ const str = std.str;
|
|||
const cstr = std.cstr;
|
||||
|
||||
|
||||
fn explicitCastMaybePointers() {
|
||||
@setFnTest(this);
|
||||
|
||||
const a: ?&i32 = undefined;
|
||||
const b: ?&f32 = (?&f32)(a);
|
||||
}
|
||||
|
||||
fn genericMallocFree() {
|
||||
@setFnTest(this, true);
|
||||
|
||||
const a = %%memAlloc(u8, 10);
|
||||
memFree(u8, a);
|
||||
}
|
||||
const some_mem : [100]u8 = undefined;
|
||||
fn memAlloc(inline T: type, n: usize) -> %[]T {
|
||||
@setFnStaticEval(this, false);
|
||||
|
||||
return (&T)(&some_mem[0])[0...n];
|
||||
}
|
||||
fn memFree(inline T: type, mem: []T) { }
|
||||
|
||||
|
||||
fn castUndefined() {
|
||||
@setFnTest(this, true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue