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
signature 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,...@@ -15452,6 +15452,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,
15452 if (is_pointery_and_elem_is_not_pointery(actual_type)) {15452 if (is_pointery_and_elem_is_not_pointery(actual_type)) {
15453 ZigType *dest_ptr_type = nullptr;15453 ZigType *dest_ptr_type = nullptr;
15454 if (wanted_type->id == ZigTypeIdPointer &&15454 if (wanted_type->id == ZigTypeIdPointer &&
15455 actual_type->id != ZigTypeIdOptional &&
15455 wanted_type->data.pointer.child_type == ira->codegen->builtin_types.entry_c_void)15456 wanted_type->data.pointer.child_type == ira->codegen->builtin_types.entry_c_void)
15456 {15457 {
15457 dest_ptr_type = wanted_type;15458 dest_ptr_type = wanted_type;
test/compile_errors.zig+11-1
...@@ -7571,6 +7571,16 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7571,6 +7571,16 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7571 \\ return -y;7571 \\ return -y;
7572 \\}7572 \\}
7573 , &[_][]const u8{7573 , &[_][]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'",
7575 });7585 });
7576}7586}