parent
dd5b2d1b04
commit
9c9eefc841
@ -1470,7 +1470,8 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) {
|
||||
case ZigTypeIdArray:
|
||||
return type_allowed_in_extern(g, type_entry->data.array.child_type);
|
||||
case ZigTypeIdFn:
|
||||
return type_entry->data.fn.fn_type_id.cc == CallingConventionC;
|
||||
return type_entry->data.fn.fn_type_id.cc == CallingConventionC ||
|
||||
type_entry->data.fn.fn_type_id.cc == CallingConventionStdcall;
|
||||
case ZigTypeIdPointer:
|
||||
if (type_size(g, type_entry) == 0)
|
||||
return false;
|
||||
|
@ -191,3 +191,17 @@ test "return inner function which references comptime variable of outer function
|
||||
var func = outer(10);
|
||||
assert(func(3) == 7);
|
||||
}
|
||||
|
||||
test "extern struct with stdcallcc fn pointer" {
|
||||
const S = extern struct {
|
||||
ptr: stdcallcc fn () i32,
|
||||
|
||||
stdcallcc fn foo() i32 {
|
||||
return 1234;
|
||||
}
|
||||
};
|
||||
|
||||
var s: S = undefined;
|
||||
s.ptr = S.foo;
|
||||
assert(s.ptr() == 1234);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user