| author | |
| committer | |
| log | 3d1652070acd01b7c871615702916425cd292a8a |
| tree | 8f4a270c2a0db5a68dd1986bd75460d425065b12 |
| parent | f7a76bdfe3bc05034f895913261a743a83ca3c78 |
| signature |
closes #14642 with modified fix suggested by Vexu in
https://github.com/ziglang/zig/issues/14642#issuecomment-17754760422 files changed, 12 insertions(+), 0 deletions(-)
src/translate_c.zig+4| ... | ... | @@ -5793,6 +5793,10 @@ fn macroIntToBool(c: *Context, node: Node) !Node { |
| 5793 | 5793 | if (isBoolRes(node)) { |
| 5794 | 5794 | return node; |
| 5795 | 5795 | } |
| 5796 | if (node.tag() == .string_literal) { | |
| 5797 | const int_from_ptr = try Tag.int_from_ptr.create(c.arena, node); | |
| 5798 | return Tag.not_equal.create(c.arena, .{ .lhs = int_from_ptr, .rhs = Tag.zero_literal.init() }); | |
| 5799 | } | |
| 5796 | 5800 | |
| 5797 | 5801 | return Tag.not_equal.create(c.arena, .{ .lhs = node, .rhs = Tag.zero_literal.init() }); |
| 5798 | 5802 | } |
test/cases/translate_c/assert_with_strlit.c created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | ||
| 2 | void assert(int x) {} | |
| 3 | #define FOO assert(0 && "error message") | |
| 4 | ||
| 5 | // translate-c | |
| 6 | // c_frontend=clang | |
| 7 | // | |
| 8 | // pub const FOO = assert((@as(c_int, 0) != 0) and (@intFromPtr("error message") != 0)); |