diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-04-01 11:35:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-01 11:35:03 -0400 |
| commit | 3c27d9c25a836a3d28f05509a7a77cb33d428dbd (patch) | |
| tree | 96030724b5b3298e8f734ada4199c7ef684fb9b4 /src/ir.cpp | |
| parent | 3199792ade2dfcb88f6668849c54352e51fc1ae0 (diff) | |
| parent | b7aa289ae45eb281968a48f21d3ecaf1fb86d830 (diff) | |
| download | zig-3c27d9c25a836a3d28f05509a7a77cb33d428dbd.tar.gz zig-3c27d9c25a836a3d28f05509a7a77cb33d428dbd.zip | |
Merge pull request #2147 from emekoi/fix1940
added error for implicit cast from *const T to *[1]T.
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 52f8f2b935..f0387e6ab3 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11090,6 +11090,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou Error err; if ((err = type_resolve(ira->codegen, target->value.type->data.pointer.child_type, ResolveStatusAlignmentKnown))) return ira->codegen->invalid_instruction; + assert((wanted_type->data.pointer.is_const && target->value.type->data.pointer.is_const) || !target->value.type->data.pointer.is_const); wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value.type)); ZigType *array_type = wanted_type->data.pointer.child_type; assert(array_type->id == ZigTypeIdArray); @@ -11651,7 +11652,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst if (array_type->id == ZigTypeIdArray && array_type->data.array.len == 1 && types_match_const_cast_only(ira, array_type->data.array.child_type, actual_type->data.pointer.child_type, source_node, - !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) + !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk && + // This should be the job of `types_match_const_cast_only` + // but `types_match_const_cast_only` only gets info for child_types + ((wanted_type->data.pointer.is_const && actual_type->data.pointer.is_const) || + !actual_type->data.pointer.is_const)) { if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
