| author | |
| committer | |
| log | f5553bfefcca2690b557ea080d8ae431b7d9b5d9 |
| tree | c2149c305441eeb6683a28effaf4a2e680bc69ac |
| parent | df589eecd61a4a2c93922302f8f486f18d0ff06b |
2 files changed, 7 insertions(+), 0 deletions(-)
src/translate_c.zig+1| ... | ... | @@ -1990,6 +1990,7 @@ fn transImplicitCastExpr( |
| 1990 | 1990 | |
| 1991 | 1991 | fn isBuiltinDefined(name: []const u8) bool { |
| 1992 | 1992 | inline for (meta.declarations(std.zig.c_builtins)) |decl| { |
| 1993 | if (!decl.is_pub) continue; | |
| 1993 | 1994 | if (std.mem.eql(u8, name, decl.name)) return true; |
| 1994 | 1995 | } |
| 1995 | 1996 | return false; |
test/translate_c.zig+6| ... | ... | @@ -3672,4 +3672,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3672 | 3672 | , &[_][]const u8{ |
| 3673 | 3673 | \\pub const FOO = __builtin_popcount; |
| 3674 | 3674 | }); |
| 3675 | ||
| 3676 | cases.add("Only consider public decls in `isBuiltinDefined`", | |
| 3677 | \\#define FOO std | |
| 3678 | , &[_][]const u8{ | |
| 3679 | \\pub const FOO = @compileError("unable to translate macro: undefined identifier `std`"); | |
| 3680 | }); | |
| 3675 | 3681 | } |