mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
c: cast NULL in advance to avoid comparison warnings
This commit is contained in:
parent
497329622a
commit
3b501b2d81
@ -655,11 +655,11 @@ pub const DeclGen = struct {
|
||||
return dg.fail("TODO: C backend: implement lowering large float values", .{});
|
||||
},
|
||||
.Pointer => switch (val.tag()) {
|
||||
.null_value => try writer.writeAll("NULL"),
|
||||
// Technically this should produce NULL but the integer literal 0 will always coerce
|
||||
// to the assigned pointer type. Note this is just a hack to fix warnings from ordered comparisons (<, >, etc)
|
||||
// between pointers and 0, which is an extension to begin with.
|
||||
.zero => try writer.writeByte('0'),
|
||||
.null_value, .zero => {
|
||||
try writer.writeAll("((");
|
||||
try dg.renderTypecast(writer, ty);
|
||||
try writer.writeAll(")NULL)");
|
||||
},
|
||||
.variable => {
|
||||
const decl = val.castTag(.variable).?.data.owner_decl;
|
||||
return dg.renderDeclValue(writer, ty, val, decl);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user