Commit f5553bfefc

Evan Haas <evan@lagerdata.com>
2021-08-31 22:33:44
translate-c: Only consider public decls in isBuiltinDefined
1 parent df589ee
Changed files (2)
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`");
+    });
 }