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 {...@@ -138,7 +138,7 @@ const Scope = struct {
138 }138 }
139139
140 /// Given the desired name, return a name that does not shadow anything from outer scopes.140 /// 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.
142 /// Will allow `name` to be one of the preprocessed decl or macro names, but will not142 /// Will allow `name` to be one of the preprocessed decl or macro names, but will not
143 /// choose a mangled name that matches one of those.143 /// choose a mangled name that matches one of those.
144 fn makeMangledName(scope: *Root, name: []const u8) ![]const u8 {144 fn makeMangledName(scope: *Root, name: []const u8) ![]const u8 {
...@@ -4328,9 +4328,12 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {...@@ -4328,9 +4328,12 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
4328 const begin_loc = ZigClangMacroDefinitionRecord_getSourceRange_getBegin(macro);4328 const begin_loc = ZigClangMacroDefinitionRecord_getSourceRange_getBegin(macro);
43294329
4330 const name = try c.str(raw_name);4330 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
4332 const begin_c = ZigClangSourceManager_getCharacterData(c.source_manager, begin_loc);4335 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) {
4334 error.OutOfMemory => |e| return e,4337 error.OutOfMemory => |e| return e,
4335 else => {4338 else => {
4336 continue;4339 continue;
...@@ -4357,9 +4360,6 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {...@@ -4357,9 +4360,6 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
4357 else => {},4360 else => {},
4358 }4361 }
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);
4363 const macro_fn = if (tok_it.peek().?.id == .Fn) blk: {4363 const macro_fn = if (tok_it.peek().?.id == .Fn) blk: {
4364 _ = tok_it.next();4364 _ = tok_it.next();
4365 break :blk true;4365 break :blk true;