diff --git a/src/libasr/runtime/lfortran_intrinsics.c b/src/libasr/runtime/lfortran_intrinsics.c index 398bc5993ff..d7a4f8f7b52 100644 --- a/src/libasr/runtime/lfortran_intrinsics.c +++ b/src/libasr/runtime/lfortran_intrinsics.c @@ -1683,10 +1683,11 @@ LFORTRAN_API void _lfortran_rewind(int32_t unit_num) LFORTRAN_API void _lfortran_read_int32(int32_t *p, int32_t unit_num) { + size_t tmp; if (unit_num == -1) { // Read from stdin FILE *fp = fdopen(0, "r+"); - (void)fread(p, sizeof(int32_t), 1, fp); + tmp = fread(p, sizeof(int32_t), 1, fp); fclose(fp); return; } @@ -1694,16 +1695,18 @@ LFORTRAN_API void _lfortran_read_int32(int32_t *p, int32_t unit_num) printf("No file found with given unit\n"); exit(1); } - (void)fread(p, sizeof(int32_t), 1, unit_to_file[unit_num]); + tmp = fread(p, sizeof(int32_t), 1, unit_to_file[unit_num]); + if (tmp) {} } LFORTRAN_API void _lfortran_read_char(char **p, int32_t unit_num) { + size_t tmp; if (unit_num == -1) { // Read from stdin *p = (char*)malloc(16); FILE *fp = fdopen(0, "r+"); - (void)fread(*p, sizeof(char), 16, fp); + tmp = fread(*p, sizeof(char), 16, fp); fclose(fp); return; } @@ -1712,7 +1715,8 @@ LFORTRAN_API void _lfortran_read_char(char **p, int32_t unit_num) exit(1); } *p = (char*)malloc(16); - (void)fread(*p, sizeof(char), 16, unit_to_file[unit_num]); + tmp = fread(*p, sizeof(char), 16, unit_to_file[unit_num]); + if (tmp) {} } LFORTRAN_API char* _lpython_read(int64_t fd, int64_t n) diff --git a/src/lpython/parser/parser.cpp b/src/lpython/parser/parser.cpp index 381b7c5587f..92ab5023a7f 100644 --- a/src/lpython/parser/parser.cpp +++ b/src/lpython/parser/parser.cpp @@ -117,7 +117,7 @@ Result parse_python_file(Allocator &al, const std::string &infile, diag::Diagnostics &diagnostics, uint32_t prev_loc, - bool new_parser) { + [[maybe_unused]] bool new_parser) { LPython::AST::ast_t* ast; // We will be using the new parser from now on new_parser = true; diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index d74fef1ef25..ba4ea076023 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -831,6 +831,8 @@ class CommonVisitor : public AST::BaseVisitor { this->visit_expr(*exprs[i]); ASR::expr_t* expr = nullptr; ASR::call_arg_t arg; + arg.loc.first = -1; + arg.loc.last = -1; if (tmp) { expr = ASRUtils::EXPR(tmp); arg.loc = expr->base.loc; @@ -1009,7 +1011,7 @@ class CommonVisitor : public AST::BaseVisitor { ASR::ttype_t* get_type_from_var_annotation(std::string var_annotation, const Location& loc, Vec& dims, - AST::expr_t** m_args=nullptr, size_t n_args=0, + AST::expr_t** m_args=nullptr, [[maybe_unused]] size_t n_args=0, bool raise_error=true, ASR::abiType abi=ASR::abiType::Source, bool is_argument=false) { ASR::ttype_t* type = nullptr; @@ -2364,7 +2366,7 @@ class CommonVisitor : public AST::BaseVisitor { result = left_value >> right_value; break; } - default: { LCOMPILERS_ASSERT(false); } // should never happen + default: { throw SemanticError("ICE: Unknown binary operator", loc); } // should never happen } value = ASR::down_cast(ASR::make_IntegerConstant_t( al, loc, result, dest_type)); @@ -2418,7 +2420,7 @@ class CommonVisitor : public AST::BaseVisitor { result = left_value >> right_value; break; } - default: { LCOMPILERS_ASSERT(false); } // should never happen + default: { throw SemanticError("ICE: Unknown binary operator", loc); } // should never happen } value = ASR::down_cast(ASR::make_UnsignedIntegerConstant_t( al, loc, result, dest_type)); @@ -2460,7 +2462,7 @@ class CommonVisitor : public AST::BaseVisitor { case (ASR::binopType::Mul): { result = left_value * right_value; break; } case (ASR::binopType::Div): { result = left_value / right_value; break; } case (ASR::binopType::Pow): { result = std::pow(left_value, right_value); break; } - default: { LCOMPILERS_ASSERT(false); } + default: { throw SemanticError("ICE: Unknown binary operator", loc); } } value = ASR::down_cast(ASR::make_RealConstant_t( al, loc, result, dest_type)); @@ -3293,7 +3295,7 @@ class CommonVisitor : public AST::BaseVisitor { void visit_NamedExpr(const AST::NamedExpr_t &x) { this->visit_expr(*x.m_target); ASR::expr_t *target = ASRUtils::EXPR(tmp); - ASR::ttype_t *target_type = ASRUtils::expr_type(target); + [[maybe_unused]] ASR::ttype_t *target_type = ASRUtils::expr_type(target); this->visit_expr(*x.m_value); ASR::expr_t *value = ASRUtils::EXPR(tmp); ASR::ttype_t *value_type = ASRUtils::expr_type(value); @@ -3400,7 +3402,7 @@ class CommonVisitor : public AST::BaseVisitor { ASR::expr_t *left = ASRUtils::EXPR(tmp); this->visit_expr(*x.m_right); ASR::expr_t *right = ASRUtils::EXPR(tmp); - ASR::binopType op; + ASR::binopType op = ASR::binopType::Add /* temporary assignment */; std::string op_name = ""; switch (x.m_op) { case (AST::operatorType::Add) : { op = ASR::binopType::Add; break; } @@ -5611,7 +5613,7 @@ class BodyVisitor : public CommonVisitor { ASR::expr_t *right = ASRUtils::EXPR(tmp); ASR::ttype_t* left_type = ASRUtils::expr_type(left); ASR::ttype_t* right_type = ASRUtils::expr_type(right); - ASR::binopType op; + ASR::binopType op = ASR::binopType::Add /* temporary assignment */; std::string op_name = ""; switch (x.m_op) { case (AST::operatorType::Add) : { op = ASR::binopType::Add; break; } @@ -6322,7 +6324,9 @@ class BodyVisitor : public CommonVisitor { result = (strcmp < 0 || strcmp == 0); break; } - default: LCOMPILERS_ASSERT(false); // should never happen + default: { + throw SemanticError("ICE: Unknown compare operator", x.base.base.loc); // should never happen + } } value = ASR::down_cast(ASR::make_LogicalConstant_t( al, x.base.base.loc, result, type));