Skip to content

Commit 77aa0d0

Browse files
committed
C: support unsigned integers in pointers
1 parent 768cb11 commit 77aa0d0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libasr/codegen/asr_to_c.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,27 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
250250
std::string dims = convert_dims_c(n_dims, m_dims, v_m_type, is_fixed_size);
251251
sub = format_type_c(dims, type_name, v.m_name, use_ref, dummy);
252252
}
253+
} else if (ASRUtils::is_unsigned_integer(*t2)) {
254+
ASR::UnsignedInteger_t *t = ASR::down_cast<ASR::UnsignedInteger_t>(ASRUtils::type_get_past_array(t2));
255+
std::string type_name = "uint" + std::to_string(t->m_kind * 8) + "_t";
256+
if( !ASRUtils::is_array(v_m_type) ) {
257+
type_name.append(" *");
258+
}
259+
if( is_array ) {
260+
bool is_fixed_size = true;
261+
std::string dims = convert_dims_c(n_dims, m_dims, v_m_type, is_fixed_size, true);
262+
std::string encoded_type_name = "u" + std::to_string(t->m_kind * 8);
263+
generate_array_decl(sub, std::string(v.m_name), type_name, dims,
264+
encoded_type_name, m_dims, n_dims,
265+
use_ref, dummy,
266+
v.m_intent != ASRUtils::intent_in &&
267+
v.m_intent != ASRUtils::intent_inout &&
268+
v.m_intent != ASRUtils::intent_out, is_fixed_size, true);
269+
} else {
270+
bool is_fixed_size = true;
271+
std::string dims = convert_dims_c(n_dims, m_dims, v_m_type, is_fixed_size);
272+
sub = format_type_c(dims, type_name, v.m_name, use_ref, dummy);
273+
}
253274
} else if (ASRUtils::is_real(*t2)) {
254275
ASR::Real_t *t = ASR::down_cast<ASR::Real_t>(t2);
255276
std::string type_name;

0 commit comments

Comments
 (0)