mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
aro_translate_c: handle opaque struct defs in prototypes
This commit is contained in:
parent
93a502cb2f
commit
b3f5769930
@ -398,6 +398,11 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_ty: Type) Error!void {
|
||||
|
||||
const is_pub = toplevel and !is_unnamed;
|
||||
const init_node = blk: {
|
||||
if (record_decl.isIncomplete()) {
|
||||
try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl), {});
|
||||
break :blk ZigTag.opaque_literal.init();
|
||||
}
|
||||
|
||||
var fields = try std.ArrayList(ast.Payload.Record.Field).initCapacity(c.gpa, record_decl.fields.len);
|
||||
defer fields.deinit();
|
||||
|
||||
|
10
test/cases/translate_c/struct prototype used in func.c
Normal file
10
test/cases/translate_c/struct prototype used in func.c
Normal file
@ -0,0 +1,10 @@
|
||||
struct Foo;
|
||||
struct Foo *some_func(struct Foo *foo, int x);
|
||||
|
||||
// translate-c
|
||||
// c_frontend=clang,aro
|
||||
//
|
||||
// pub const struct_Foo = opaque {};
|
||||
// pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo;
|
||||
//
|
||||
// pub const Foo = struct_Foo;
|
@ -879,17 +879,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\pub const Foo = struct_Foo;
|
||||
});
|
||||
|
||||
cases.add("struct prototype used in func",
|
||||
\\struct Foo;
|
||||
\\struct Foo *some_func(struct Foo *foo, int x);
|
||||
, &[_][]const u8{
|
||||
\\pub const struct_Foo = opaque {};
|
||||
,
|
||||
\\pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo;
|
||||
,
|
||||
\\pub const Foo = struct_Foo;
|
||||
});
|
||||
|
||||
cases.add("#define an unsigned integer literal",
|
||||
\\#define CHANNEL_COUNT 24
|
||||
, &[_][]const u8{
|
||||
|
Loading…
Reference in New Issue
Block a user