| author | |
| committer | |
| log | b3f576993087f90a249b75f8e72cb95974633eb4 |
| tree | df23ac9ec790d6358290ab15947a47befba385a1 |
| parent | 93a502cb2f5a38d0a94ebccd1be523bc71f6a00b |
| signature |
3 files changed, 15 insertions(+), 11 deletions(-)
lib/compiler/aro_translate_c.zig+5| ... | ... | @@ -398,6 +398,11 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_ty: Type) Error!void { |
| 398 | 398 | |
| 399 | 399 | const is_pub = toplevel and !is_unnamed; |
| 400 | 400 | const init_node = blk: { |
| 401 | if (record_decl.isIncomplete()) { | |
| 402 | try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl), {}); | |
| 403 | break :blk ZigTag.opaque_literal.init(); | |
| 404 | } | |
| 405 | ||
| 401 | 406 | var fields = try std.ArrayList(ast.Payload.Record.Field).initCapacity(c.gpa, record_decl.fields.len); |
| 402 | 407 | defer fields.deinit(); |
| 403 | 408 |
test/cases/translate_c/struct prototype used in func.c	 created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | struct Foo; | |
| 2 | struct Foo *some_func(struct Foo *foo, int x); | |
| 3 | ||
| 4 | // translate-c | |
| 5 | // c_frontend=clang,aro | |
| 6 | // | |
| 7 | // pub const struct_Foo = opaque {}; | |
| 8 | // pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo; | |
| 9 | // | |
| 10 | // pub const Foo = struct_Foo; |
test/translate_c.zig-11| ... | ... | @@ -879,17 +879,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 879 | 879 | \\pub const Foo = struct_Foo; |
| 880 | 880 | }); |
| 881 | 881 | |
| 882 | cases.add("struct prototype used in func", | |
| 883 | \\struct Foo; | |
| 884 | \\struct Foo *some_func(struct Foo *foo, int x); | |
| 885 | , &[_][]const u8{ | |
| 886 | \\pub const struct_Foo = opaque {}; | |
| 887 | , | |
| 888 | \\pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo; | |
| 889 | , | |
| 890 | \\pub const Foo = struct_Foo; | |
| 891 | }); | |
| 892 | ||
| 893 | 882 | cases.add("#define an unsigned integer literal", |
| 894 | 883 | \\#define CHANNEL_COUNT 24 |
| 895 | 884 | , &[_][]const u8{ |