Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ RUN(NAME expr_20 LABELS cpython llvm c)
RUN(NAME expr_01u LABELS cpython llvm c NOFAST)
RUN(NAME expr_02u LABELS cpython llvm c NOFAST)
RUN(NAME expr_03u LABELS cpython llvm c NOFAST)
RUN(NAME expr_04u LABELS cpython llvm c)

RUN(NAME loop_01 LABELS cpython llvm c)
RUN(NAME loop_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/expr_04u.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from lpython import u8, u16, u32, u64

FLAG1 : u8 = u8(1) << u8(4)
FLAG2 : u16 = u16(1) << u16(4)
FLAG3: u32 = u32(1) << u32(4)
FLAG4: u64 = u64(1) << u64(4)

print(FLAG1, FLAG2, FLAG3, FLAG4)
assert FLAG1 == u8(16)
assert FLAG2 == u16(16)
assert FLAG3 == u32(16)
assert FLAG4 == u64(16)
5 changes: 3 additions & 2 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2353,8 +2353,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
this->visit_expr_wrapper(x.m_symbolic_value, true);
init_value = llvm::dyn_cast<llvm::Constant>(tmp);
}
if (x.m_type->type == ASR::ttypeType::Integer) {
int a_kind = down_cast<ASR::Integer_t>(x.m_type)->m_kind;
if (x.m_type->type == ASR::ttypeType::Integer
|| x.m_type->type == ASR::ttypeType::UnsignedInteger) {
int a_kind = ASRUtils::extract_kind_from_ttype_t(x.m_type);
llvm::Type *type;
int init_value_bits = 8*a_kind;
type = llvm_utils->getIntType(a_kind);
Expand Down