Skip to content

Commit a03d6a5

Browse files
authored
Merge pull request #1061 from ronnuriel/feature/Binary_op_support
Added binary op and set & op precedence back to 11 (same as the table)
2 parents d79ad27 + f703df7 commit a03d6a5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

integration_tests/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ RUN(NAME expr_01 LABELS cpython llvm c)
134134
RUN(NAME expr_02 LABELS cpython llvm c)
135135
RUN(NAME expr_03 LABELS cpython llvm c)
136136
RUN(NAME expr_04 LABELS cpython llvm c)
137-
RUN(NAME expr_05 LABELS cpython llvm)
137+
RUN(NAME expr_05 LABELS cpython llvm c)
138138
RUN(NAME expr_06 LABELS cpython llvm c)
139139
RUN(NAME expr_07 LABELS cpython llvm)
140140
RUN(NAME expr_08 LABELS llvm c)

src/libasr/codegen/asr_to_c_cpp.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,11 @@ R"(#include <stdio.h>
823823
case (ASR::binopType::Sub) : { last_expr_precedence = 6; break; }
824824
case (ASR::binopType::Mul) : { last_expr_precedence = 5; break; }
825825
case (ASR::binopType::Div) : { last_expr_precedence = 5; break; }
826-
case (ASR::binopType::BitAnd) : { last_expr_precedence = 5; break; }
826+
case (ASR::binopType::BitAnd) : { last_expr_precedence = 11; break; }
827+
case (ASR::binopType::BitOr) : { last_expr_precedence = 13; break; }
828+
case (ASR::binopType::BitXor) : { last_expr_precedence = 12; break; }
829+
case (ASR::binopType::BitLShift) : { last_expr_precedence = 7; break; }
830+
case (ASR::binopType::BitRShift) : { last_expr_precedence = 7; break; }
827831
case (ASR::binopType::Pow) : {
828832
src = "pow(" + left + ", " + right + ")";
829833
if (is_c) {

0 commit comments

Comments
 (0)