Commit ad27041de9
Changed files (2)
src-self-hosted
test
src-self-hosted/translate_c.zig
@@ -810,8 +810,10 @@ fn transRecordDecl(c: *Context, record_decl: *const ZigClangRecordDecl) Error!?*
_ = try appendToken(c, .Colon, ":");
const field_type = transQualType(rp, ZigClangFieldDecl_getType(field_decl), field_loc) catch |err| switch (err) {
error.UnsupportedType => {
- try failDecl(c, record_loc, name, "unable to translate {} member type", .{container_kind_name});
- return null;
+ const opaque = try transCreateNodeOpaqueType(c);
+ semicolon = try appendToken(c, .Semicolon, ";");
+ try emitWarning(c, record_loc, "{} demoted to opaque type - unable to translate type of field {}", .{ container_kind_name, raw_name });
+ break :blk opaque;
},
else => |e| return e,
};
test/translate_c.zig
@@ -41,6 +41,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub const FOO = -BAR;
});
+ cases.add("struct with atomic field",
+ \\struct arcan_shmif_cont {
+ \\ struct arcan_shmif_page* addr;
+ \\};
+ \\struct arcan_shmif_page {
+ \\ volatile _Atomic int abufused[12];
+ \\};
+ , &[_][]const u8{
+ \\pub const struct_arcan_shmif_page = //
+ ,
+ \\warning: unsupported type: 'Atomic'
+ \\ @OpaqueType(); //
+ ,
+ \\ warning: struct demoted to opaque type - unable to translate type of field abufused
+ , // TODO should be `addr: *struct_arcan_shmif_page`
+ \\pub const struct_arcan_shmif_cont = extern struct {
+ \\ addr: [*c]struct_arcan_shmif_page,
+ \\};
+ });
+
cases.add("function prototype translated as optional",
\\typedef void (*fnptr_ty)(void);
\\typedef __attribute__((cdecl)) void (*fnptr_attr_ty)(void);