translate-c: Only consider public decls in isBuiltinDefined

This commit is contained in:
Evan Haas 2021-08-31 13:33:44 -07:00 committed by Andrew Kelley
parent df589eecd6
commit f5553bfefc
2 changed files with 7 additions and 0 deletions

View File

@ -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;

View File

@ -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`");
});
}