Skip to content

Commit 365a612

Browse files
committed
translate-c: fix regression from previous commit
This made macros which had an error being processed emit multiple times, causing the self-hosted compiler to fail to build.
1 parent ec09b9e commit 365a612

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src-self-hosted/translate_c.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const Scope = struct {
138138
}
139139

140140
/// Given the desired name, return a name that does not shadow anything from outer scopes.
141-
/// Inserts the returned name into the scope.
141+
/// Does not insert the returned name into the scope.
142142
/// Will allow `name` to be one of the preprocessed decl or macro names, but will not
143143
/// choose a mangled name that matches one of those.
144144
fn makeMangledName(scope: *Root, name: []const u8) ![]const u8 {
@@ -4328,9 +4328,12 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
43284328
const begin_loc = ZigClangMacroDefinitionRecord_getSourceRange_getBegin(macro);
43294329

43304330
const name = try c.str(raw_name);
4331+
// TODO https://github.com/ziglang/zig/issues/3756
4332+
// TODO https://github.com/ziglang/zig/issues/1802
4333+
const mangled_name = try scope.makeMangledName(name);
43314334

43324335
const begin_c = ZigClangSourceManager_getCharacterData(c.source_manager, begin_loc);
4333-
ctok.tokenizeCMacro(c, begin_loc, name, &tok_list, begin_c) catch |err| switch (err) {
4336+
ctok.tokenizeCMacro(c, begin_loc, mangled_name, &tok_list, begin_c) catch |err| switch (err) {
43344337
error.OutOfMemory => |e| return e,
43354338
else => {
43364339
continue;
@@ -4357,9 +4360,6 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
43574360
else => {},
43584361
}
43594362

4360-
// TODO https://github.com/ziglang/zig/issues/3756
4361-
// TODO https://github.com/ziglang/zig/issues/1802
4362-
const mangled_name = try scope.makeMangledName(name);
43634363
const macro_fn = if (tok_it.peek().?.id == .Fn) blk: {
43644364
_ = tok_it.next();
43654365
break :blk true;

0 commit comments

Comments
 (0)