Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abcbc35

Browse files
committed
ASR: Support CPtr cast to bool()
1 parent a0a7813 commit abcbc35

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lpython/semantics/python_intrinsic_eval.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ struct IntrinsicNodeHandler {
244244

245245
} else if (ASRUtils::is_logical(*type)) {
246246
return (ASR::asr_t *)arg;
247+
} else if (ASR::is_a<ASR::CPtr_t>(*type)) {
248+
ASR::expr_t* c_null_ptr = ASRUtils::EXPR(ASR::make_PointerNullConstant_t(
249+
al, loc, ASRUtils::TYPE(ASR::make_CPtr_t(al, loc))));
250+
return ASR::make_CPtrCompare_t(al, loc, arg, ASR::cmpopType::NotEq, c_null_ptr, to_type, nullptr);
247251
} else {
248252
std::string stype = ASRUtils::type_to_str_python(type);
249253
throw SemanticError(

0 commit comments

Comments
 (0)