Skip to content

Commit d3f3fe4

Browse files
committed
Use empty_c_void_p for nullptr constant
1 parent 26e4604 commit d3f3fe4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5766,6 +5766,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
57665766
x.base.base.loc);
57675767
}
57685768
tmp = ASR::make_ListCompare_t(al, x.base.base.loc, left, asr_op, right, type, value);
5769+
} else if (ASR::is_a<ASR::CPtr_t>(*dest_type)) {
5770+
tmp = ASR::make_CPtrCompare_t(al, x.base.base.loc, left, asr_op, right, type, value);
57695771
} else {
57705772
throw SemanticError("Compare not supported for type: " + ASRUtils::type_to_str_python(dest_type),
57715773
x.base.base.loc);
@@ -6804,7 +6806,8 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
68046806
} else if (call_name == "empty_c_void_p") {
68056807
// TODO: check that `empty_c_void_p uses` has arguments that are compatible
68066808
// with the type
6807-
tmp = nullptr;
6809+
ASR::ttype_t* type = ASRUtils::TYPE(ASR::make_CPtr_t(al, x.base.base.loc));
6810+
tmp = ASR::make_PointerNullConstant_t(al, x.base.base.loc, type);
68086811
return;
68096812
} else if (call_name == "TypeVar") {
68106813
// Ignore TypeVar for now, we handle it based on the identifier itself

0 commit comments

Comments
 (0)