authorgravatar for arbrk1@users.noreply.github.comarbrk1 <arbrk1@users.noreply.github.com> 2020-06-25 06:58:50+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-06-24 23:58:50-04:00
log78d8931647f207965ef98354db67fb880987fafe
tree4320918a2e9d4c57485bcae9af34de2bdafd1768
parent2fde8249b72f22ddfa16793c245315f30c7f3ff8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Fix issue #5618 (#5685)

* fix issue #5618 * A test for the issue #5618 added. Also inserted a comma in the neighboring test to make it more zigfmt-friendly.

2 files changed, 12 insertions(+), 1 deletions(-)

src/ir.cpp+1
......@@ -15452,6 +15452,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,
1545215452 if (is_pointery_and_elem_is_not_pointery(actual_type)) {
1545315453 ZigType *dest_ptr_type = nullptr;
1545415454 if (wanted_type->id == ZigTypeIdPointer &&
15455 actual_type->id != ZigTypeIdOptional &&
1545515456 wanted_type->data.pointer.child_type == ira->codegen->builtin_types.entry_c_void)
1545615457 {
1545715458 dest_ptr_type = wanted_type;
test/compile_errors.zig+11-1
......@@ -7571,6 +7571,16 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
75717571 \\ return -y;
75727572 \\}
75737573 , &[_][]const u8{
7574 "tmp.zig:3:12: error: negation of type 'u32'"
7574 "tmp.zig:3:12: error: negation of type 'u32'",
7575 });
7576
7577 cases.add("Issue #5618: coercion of ?*c_void to *c_void must fail.",
7578 \\export fn foo() void {
7579 \\ var u: ?*c_void = null;
7580 \\ var v: *c_void = undefined;
7581 \\ v = u;
7582 \\}
7583 , &[_][]const u8{
7584 "tmp.zig:4:9: error: expected type '*c_void', found '?*c_void'",
75757585 });
75767586}