diff options
| author | Ben Noordhuis <info@bnoordhuis.nl> | 2018-02-26 18:40:33 +0100 |
|---|---|---|
| committer | Ben Noordhuis <info@bnoordhuis.nl> | 2018-02-26 19:56:26 +0100 |
| commit | 9aa65c0e8e6e4135dcc04bcb388d1fa38c6d10f6 (patch) | |
| tree | d7bedb06367d28f4851fc2020f3fa6ca84b96294 /src/ir.cpp | |
| parent | 1eecfdaa9b9c04e50058695b8df9978ef47f121a (diff) | |
| download | zig-9aa65c0e8e6e4135dcc04bcb388d1fa38c6d10f6.tar.gz zig-9aa65c0e8e6e4135dcc04bcb388d1fa38c6d10f6.zip | |
allow implicit cast from &const to ?&const &const
Allow implicit casts from n-th degree const pointers to nullable const
pointers of degree n+1. That is:
fn f() void {
const s = S {};
const p = &s;
g(p); // Works.
g(&p); // So does this.
}
fn g(_: ?&const &const S) void { // Nullable 2nd degree const ptr.
}
Fixes #731 some more.
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index e79235830c..b1fd7104ea 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8830,7 +8830,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst } } else if (wanted_child_type->id == TypeTableEntryIdPointer && wanted_child_type->data.pointer.is_const && - is_container(actual_type)) { + (actual_type->id == TypeTableEntryIdPointer || is_container(actual_type))) + { IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_child_type, value); if (type_is_invalid(cast1->value.type)) return ira->codegen->invalid_instruction; |
