translate-c: Only consider public decls in isBuiltinDefined
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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`");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user