Commit f5553bfefc
Changed files (2)
test
src/translate_c.zig
@@ -1990,6 +1990,7 @@ fn transImplicitCastExpr(
fn isBuiltinDefined(name: []const u8) bool {
inline for (meta.declarations(std.zig.c_builtins)) |decl| {
+ if (!decl.is_pub) continue;
if (std.mem.eql(u8, name, decl.name)) return true;
}
return false;
test/translate_c.zig
@@ -3672,4 +3672,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
, &[_][]const u8{
\\pub const FOO = __builtin_popcount;
});
+
+ cases.add("Only consider public decls in `isBuiltinDefined`",
+ \\#define FOO std
+ , &[_][]const u8{
+ \\pub const FOO = @compileError("unable to translate macro: undefined identifier `std`");
+ });
}