From 6695fa4f326e807256b9afc6321e63a90b08e1ba Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 1 Apr 2020 18:30:40 +0200 Subject: ir: Fix comparison of ?T values The code assumed that every ?T had a pointer child type T, add some more checks to make sure the type is effectively a pointer. Closes #4789 --- src/ir.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index a30d467194..5b86922be3 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11454,10 +11454,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted bool actual_allows_zero = ptr_allows_addr_zero(actual_type); bool wanted_is_c_ptr = wanted_type->id == ZigTypeIdPointer && wanted_type->data.pointer.ptr_len == PtrLenC; bool actual_is_c_ptr = actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenC; - bool wanted_opt_or_ptr = wanted_ptr_type != nullptr && - (wanted_type->id == ZigTypeIdPointer || wanted_type->id == ZigTypeIdOptional); - bool actual_opt_or_ptr = actual_ptr_type != nullptr && - (actual_type->id == ZigTypeIdPointer || actual_type->id == ZigTypeIdOptional); + bool wanted_opt_or_ptr = wanted_ptr_type != nullptr && wanted_ptr_type->id == ZigTypeIdPointer; + bool actual_opt_or_ptr = actual_ptr_type != nullptr && actual_ptr_type->id == ZigTypeIdPointer; if (wanted_opt_or_ptr && actual_opt_or_ptr) { bool ok_null_term_ptrs = wanted_ptr_type->data.pointer.sentinel == nullptr || -- cgit v1.2.3