* fix issue #5618

* A test for the issue #5618 added.
Also inserted a comma in the neighboring test to make it more zigfmt-friendly.
This commit is contained in:
arbrk1 2020-06-25 06:58:50 +03:00 committed by GitHub
parent 2fde8249b7
commit 78d8931647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -15452,6 +15452,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,
if (is_pointery_and_elem_is_not_pointery(actual_type)) {
ZigType *dest_ptr_type = nullptr;
if (wanted_type->id == ZigTypeIdPointer &&
actual_type->id != ZigTypeIdOptional &&
wanted_type->data.pointer.child_type == ira->codegen->builtin_types.entry_c_void)
{
dest_ptr_type = wanted_type;

View File

@ -7571,6 +7571,16 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ return -y;
\\}
, &[_][]const u8{
"tmp.zig:3:12: error: negation of type 'u32'"
"tmp.zig:3:12: error: negation of type 'u32'",
});
cases.add("Issue #5618: coercion of ?*c_void to *c_void must fail.",
\\export fn foo() void {
\\ var u: ?*c_void = null;
\\ var v: *c_void = undefined;
\\ v = u;
\\}
, &[_][]const u8{
"tmp.zig:4:9: error: expected type '*c_void', found '?*c_void'",
});
}