zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f5553bfefcca2690b557ea080d8ae431b7d9b5d9 (tree)
parent df589eecd61a4a2c93922302f8f486f18d0ff06b
Author: Evan Haas <evan@lagerdata.com>
Date:   Tue, 31 Aug 2021 13:33:44 -0700

translate-c: Only consider public decls in isBuiltinDefined

Diffstat:
Msrc/translate_c.zig | 1+
Mtest/translate_c.zig | 6++++++
2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/translate_c.zig b/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; diff --git a/test/translate_c.zig b/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`"); + }); }