authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-01 19:57:27-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-01 19:58:41-05:00
log365a6124d98966cb5ae1fadaec3e05b1a19c93e7
tree06475387a72d5be9d97577941388491101a72c5c
parentec09b9e5f0d2f9f603210c1d493b0e563aba13a5
signature Commit is signed but in an unrecognized format.

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 files changed, 5 insertions(+), 5 deletions(-)

src-self-hosted/translate_c.zig+5-5
......@@ -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;