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

Skip to content

CI: Check for warnings #2145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2023
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
53 changes: 51 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ jobs:

- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}

- name: Build Linux
shell: bash -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
Expand All @@ -292,8 +294,55 @@ jobs:
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache

cmake --build . -j16 --target install

- name: Test Linux
shell: bash -l {0}
run: |
ctest
./run_tests.py -s
cd integration_tests
./run_tests.py -b llvm c
./run_tests.py -b llvm c -f

release:
name: Check Release build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4

- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}

- name: Build Linux
shell: bash -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache

cmake --build . -j16 --target install

Expand Down
5 changes: 5 additions & 0 deletions build0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ python src/libasr/wasm_instructions_visitor.py
(cd src/lpython/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
(cd src/lpython/parser && bison -Wall -d -r all parser.yy)

python -c "file = 'src/lpython/parser/parser.tab.cc'
with open(file, 'r') as f: text = f.read()
with open(file, 'w') as f:
f.write('[[maybe_unused]] int yynerrs'.join(text.split('int yynerrs')))"

grep -n "'" src/lpython/parser/parser.yy && echo "Single quote not allowed" && exit 1
echo "OK"
1 change: 1 addition & 0 deletions src/libasr/pass/array_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class ReplaceArrayOp: public ASR::BaseExprReplacer<ReplaceArrayOp> {
} else if (var_rank == 0) {
ASR::do_loop_head_t head;
head.m_v = loop_vars[0];
head.loc = loop_vars[0]->base.loc;
if( use_custom_loop_params ) {
int j = loop_var_indices[0];
head.m_start = result_lbound[j];
Expand Down
12 changes: 8 additions & 4 deletions src/libasr/runtime/lfortran_intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,27 +1683,30 @@ 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;
}
if (!unit_to_file[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;
}
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/lpython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ set(SRC
utils.cpp
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set_source_files_properties(parser/parser.tab.cc PROPERTIES COMPILE_FLAGS -Wno-free-nonheap-object)
endif()

if (WITH_WHEREAMI)
set(SRC ${SRC} ../bin/tpl/whereami/whereami.cpp)
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/lpython/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Result<LPython::AST::ast_t*> 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;
Expand Down
20 changes: 12 additions & 8 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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;
Expand Down Expand Up @@ -1009,7 +1011,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {

ASR::ttype_t* get_type_from_var_annotation(std::string var_annotation,
const Location& loc, Vec<ASR::dimension_t>& 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;
Expand Down Expand Up @@ -2364,7 +2366,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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::expr_t>(ASR::make_IntegerConstant_t(
al, loc, result, dest_type));
Expand Down Expand Up @@ -2418,7 +2420,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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::expr_t>(ASR::make_UnsignedIntegerConstant_t(
al, loc, result, dest_type));
Expand Down Expand Up @@ -2460,7 +2462,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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::expr_t>(ASR::make_RealConstant_t(
al, loc, result, dest_type));
Expand Down Expand Up @@ -3293,7 +3295,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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);
Expand Down Expand Up @@ -3400,7 +3402,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
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; }
Expand Down Expand Up @@ -5611,7 +5613,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
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; }
Expand Down Expand Up @@ -6322,7 +6324,9 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
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::expr_t>(ASR::make_LogicalConstant_t(
al, x.base.base.loc, result, type));
Expand Down