| author | |
| committer | |
| log | ad27041de9b020336135c33bafbf5bf593659330 |
| tree | 0e0aaec6da5f2dbd1e67c0d399b7bd213287db41 |
| parent | b7614e63f538f0a9b3014f8b6829f0fbf68544ed |
2 files changed, 24 insertions(+), 2 deletions(-)
src-self-hosted/translate_c.zig+4-2| ... | ... | @@ -810,8 +810,10 @@ fn transRecordDecl(c: *Context, record_decl: *const ZigClangRecordDecl) Error!?* |
| 810 | 810 | _ = try appendToken(c, .Colon, ":"); |
| 811 | 811 | const field_type = transQualType(rp, ZigClangFieldDecl_getType(field_decl), field_loc) catch |err| switch (err) { |
| 812 | 812 | error.UnsupportedType => { |
| 813 | try failDecl(c, record_loc, name, "unable to translate {} member type", .{container_kind_name}); | |
| 814 | return null; | |
| 813 | const opaque = try transCreateNodeOpaqueType(c); | |
| 814 | semicolon = try appendToken(c, .Semicolon, ";"); | |
| 815 | try emitWarning(c, record_loc, "{} demoted to opaque type - unable to translate type of field {}", .{ container_kind_name, raw_name }); | |
| 816 | break :blk opaque; | |
| 815 | 817 | }, |
| 816 | 818 | else => |e| return e, |
| 817 | 819 | }; |
test/translate_c.zig+20| ... | ... | @@ -41,6 +41,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 41 | 41 | \\pub const FOO = -BAR; |
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | cases.add("struct with atomic field", | |
| 45 | \\struct arcan_shmif_cont { | |
| 46 | \\ struct arcan_shmif_page* addr; | |
| 47 | \\}; | |
| 48 | \\struct arcan_shmif_page { | |
| 49 | \\ volatile _Atomic int abufused[12]; | |
| 50 | \\}; | |
| 51 | , &[_][]const u8{ | |
| 52 | \\pub const struct_arcan_shmif_page = // | |
| 53 | , | |
| 54 | \\warning: unsupported type: 'Atomic' | |
| 55 | \\ @OpaqueType(); // | |
| 56 | , | |
| 57 | \\ warning: struct demoted to opaque type - unable to translate type of field abufused | |
| 58 | , // TODO should be `addr: *struct_arcan_shmif_page` | |
| 59 | \\pub const struct_arcan_shmif_cont = extern struct { | |
| 60 | \\ addr: [*c]struct_arcan_shmif_page, | |
| 61 | \\}; | |
| 62 | }); | |
| 63 | ||
| 44 | 64 | cases.add("function prototype translated as optional", |
| 45 | 65 | \\typedef void (*fnptr_ty)(void); |
| 46 | 66 | \\typedef __attribute__((cdecl)) void (*fnptr_attr_ty)(void); |