clean warnings
This commit is contained in:
@ -777,7 +777,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
|
||||
bool has_default = false;
|
||||
block* default_ctx = nullptr;
|
||||
|
||||
for (auto i = 0; i < stmt->stmt->list.size(); i++)
|
||||
for (auto i = 0u; i < stmt->stmt->list.size(); i++)
|
||||
{
|
||||
auto& entry = stmt->stmt->list[i];
|
||||
|
||||
@ -2296,7 +2296,7 @@ void compiler::process_stmt_while(const ast::stmt_while::ptr& stmt, const block:
|
||||
|
||||
continue_blks_.push_back(stmt->blk.get());
|
||||
|
||||
for (auto i = 0; i < continue_blks_.size(); i++)
|
||||
for (auto i = 0u; i < continue_blks_.size(); i++)
|
||||
blk->append({continue_blks_.at(i)});
|
||||
|
||||
if (const_cond) blk->append(break_blks_);
|
||||
@ -2323,7 +2323,7 @@ void compiler::process_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const bl
|
||||
|
||||
continue_blks_.push_back(stmt->blk.get());
|
||||
|
||||
for (auto i = 0; i < continue_blks_.size(); i++)
|
||||
for (auto i = 0u; i < continue_blks_.size(); i++)
|
||||
blk->append({continue_blks_.at(i)});
|
||||
|
||||
if (const_cond) blk->append(break_blks_);
|
||||
@ -2355,7 +2355,7 @@ void compiler::process_stmt_for(const ast::stmt_for::ptr& stmt, const block::ptr
|
||||
|
||||
continue_blks_.push_back(stmt->blk.get());
|
||||
|
||||
for (auto i = 0; i < continue_blks_.size(); i++)
|
||||
for (auto i = 0u; i < continue_blks_.size(); i++)
|
||||
blk->append({continue_blks_.at(i)});
|
||||
|
||||
process_stmt(stmt->iter, stmt->blk_iter);
|
||||
@ -2405,7 +2405,7 @@ void compiler::process_stmt_foreach(const ast::stmt_foreach::ptr& stmt, const bl
|
||||
|
||||
continue_blks_.push_back(stmt->ctx.get());
|
||||
|
||||
for (auto i = 0; i < continue_blks_.size(); i++)
|
||||
for (auto i = 0u; i < continue_blks_.size(); i++)
|
||||
blk->append({continue_blks_.at(i)});
|
||||
|
||||
process_expr(stmt->key_expr, stmt->ctx_post);
|
||||
@ -2425,7 +2425,7 @@ void compiler::process_stmt_switch(const ast::stmt_switch::ptr& stmt, const bloc
|
||||
|
||||
auto num = stmt->stmt->list.size();
|
||||
|
||||
for (auto i = 0; i < num; i++)
|
||||
for (auto i = 0u; i < num; i++)
|
||||
{
|
||||
auto& entry = stmt->stmt->list[0];
|
||||
|
||||
@ -2475,7 +2475,7 @@ void compiler::process_stmt_switch(const ast::stmt_switch::ptr& stmt, const bloc
|
||||
auto old_breaks = break_blks_;
|
||||
break_blks_.clear();
|
||||
|
||||
for (auto i = 0; i < stmt_list->list.size(); i++)
|
||||
for (auto i = 0u; i < stmt_list->list.size(); i++)
|
||||
{
|
||||
auto& entry = stmt_list->list[i];
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ void decompiler::decompile_infinites(const ast::stmt_list::ptr& stmt)
|
||||
|
||||
void decompiler::decompile_loops(const ast::stmt_list::ptr& stmt)
|
||||
{
|
||||
for (auto i = 0; i < stmt->list.size(); i++)
|
||||
for (auto i = 0u; i < stmt->list.size(); i++)
|
||||
{
|
||||
auto& entry = stmt->list.at(i);
|
||||
|
||||
@ -1841,7 +1841,7 @@ void decompiler::decompile_loops(const ast::stmt_list::ptr& stmt)
|
||||
|
||||
void decompiler::decompile_switches(const ast::stmt_list::ptr& stmt)
|
||||
{
|
||||
for (auto i = 0; i < stmt->list.size(); i++)
|
||||
for (auto i = 0u; i < stmt->list.size(); i++)
|
||||
{
|
||||
if (stmt->list.at(i) == ast::kind::asm_switch)
|
||||
{
|
||||
@ -1852,7 +1852,7 @@ void decompiler::decompile_switches(const ast::stmt_list::ptr& stmt)
|
||||
|
||||
void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
|
||||
{
|
||||
for (auto i = 0; i < stmt->list.size(); i++)
|
||||
for (auto i = 0u; i < stmt->list.size(); i++)
|
||||
{
|
||||
auto& entry = stmt->list.at(i);
|
||||
|
||||
@ -1927,7 +1927,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
|
||||
|
||||
void decompiler::decompile_aborts(const ast::stmt_list::ptr& block)
|
||||
{
|
||||
for (auto i = 0; i < block->list.size(); i++)
|
||||
for (auto i = 0u; i < block->list.size(); i++)
|
||||
{
|
||||
if (block->list.at(i) == ast::kind::asm_jump)
|
||||
{
|
||||
@ -2434,7 +2434,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
|
||||
auto current_case = ast::stmt(std::make_unique<ast::node>());
|
||||
|
||||
auto num = sw_stmt->list.size();
|
||||
for (auto i = 0; i < num; i++)
|
||||
for (auto i = 0u; i < num; i++)
|
||||
{
|
||||
auto& entry = sw_stmt->list[0];
|
||||
|
||||
@ -2623,15 +2623,19 @@ void decompiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block:
|
||||
process_stmt(entry, blk);
|
||||
}
|
||||
|
||||
for (auto i = 0; i < stmt->list.size(); i++)
|
||||
auto i = 0u;
|
||||
|
||||
while (i < stmt->list.size())
|
||||
{
|
||||
auto type = stmt->list.at(i).kind();
|
||||
|
||||
if (type == ast::kind::asm_create || type == ast::kind::asm_remove)
|
||||
{
|
||||
stmt->list.erase(stmt->list.begin() + i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3141,7 +3145,7 @@ void decompiler::process_expr_binary(const ast::expr_binary::ptr& expr, const bl
|
||||
|
||||
prec = expr->rvalue.as_node->precedence();
|
||||
|
||||
if (prec && prec < expr->precedence() || (prec == expr->precedence() && expr->kind() == expr->rvalue.as_node->kind()))
|
||||
if ((prec && prec < expr->precedence()) || (prec == expr->precedence() && expr->kind() == expr->rvalue.as_node->kind()))
|
||||
{
|
||||
expr->rvalue = ast::expr(std::make_unique<ast::expr_paren>(std::move(expr->rvalue)));
|
||||
}
|
||||
@ -3161,7 +3165,7 @@ void decompiler::process_expr_and(const ast::expr_and::ptr& expr, const block::p
|
||||
|
||||
prec = expr->rvalue.as_node->precedence();
|
||||
|
||||
if (prec && prec < expr->precedence() || (prec == expr->precedence() && expr->kind() == expr->rvalue.kind()))
|
||||
if ((prec && prec < expr->precedence()) || (prec == expr->precedence() && expr->kind() == expr->rvalue.kind()))
|
||||
{
|
||||
expr->rvalue = ast::expr(std::make_unique<ast::expr_paren>(std::move(expr->rvalue)));
|
||||
}
|
||||
@ -3317,7 +3321,7 @@ void decompiler::process_var_create(ast::expr& expr, const block::ptr& blk, bool
|
||||
|
||||
void decompiler::process_var_access(ast::expr& expr, const block::ptr& blk)
|
||||
{
|
||||
if (blk->local_vars.size() <= std::stoi(expr.as_asm_access->index))
|
||||
if (blk->local_vars.size() <= std::stoul(expr.as_asm_access->index))
|
||||
{
|
||||
printf("WARNING: bad local var access\n");
|
||||
}
|
||||
|
@ -86,8 +86,10 @@ bool buffer::push(char c)
|
||||
return true;
|
||||
}
|
||||
|
||||
reader::reader() : state(reader::end), buffer_pos(0),
|
||||
bytes_remaining(0), last_byte(0), current_byte(0) {}
|
||||
reader::reader() : buffer_pos(0), bytes_remaining(0), last_byte(0), current_byte(0), state(reader::end)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void reader::init(const char* data, size_t size)
|
||||
{
|
||||
@ -127,8 +129,8 @@ void reader::advance()
|
||||
}
|
||||
}
|
||||
|
||||
lexer::lexer(build mode, const std::string& name, const char* data, size_t size) : indev_(false), clean_(true), loc_(location(&name)),
|
||||
mode_(mode), header_top_(0), locs_(std::stack<location>()), readers_(std::stack<reader>())
|
||||
lexer::lexer(build mode, const std::string& name, const char* data, size_t size) : loc_(location(&name)),
|
||||
locs_(std::stack<location>()), readers_(std::stack<reader>()), header_top_(0), mode_(mode), indev_(false), clean_(true)
|
||||
{
|
||||
reader_.init(data, size);
|
||||
}
|
||||
@ -480,7 +482,7 @@ auto lexer::lex() -> parser::symbol_type
|
||||
default:
|
||||
if (last >= '0' && last <= '9')
|
||||
goto lex_number;
|
||||
else if (last == '_' || last >= 'A' && last <= 'Z' || last >= 'a' && last <= 'z')
|
||||
else if (last == '_' || (last >= 'A' && last <= 'Z') || (last >= 'a' && last <= 'z'))
|
||||
goto lex_name;
|
||||
|
||||
throw comp_error(loc_, utils::string::va("bad token: \'%c\'", last));
|
||||
@ -643,7 +645,7 @@ lex_number:
|
||||
if (last == '\'')
|
||||
throw comp_error(loc_, "invalid number literal");
|
||||
|
||||
if (dot > 1 || flt > 1 || flt && buffer_.data[buffer_.length - 1] != 'f')
|
||||
if (dot > 1 || flt > 1 || (flt && buffer_.data[buffer_.length - 1] != 'f'))
|
||||
throw comp_error(loc_, "invalid number literal");
|
||||
|
||||
if (dot || flt)
|
||||
@ -660,7 +662,7 @@ lex_number:
|
||||
if (state == reader::end)
|
||||
break;
|
||||
|
||||
if (curr == '\'' && (last == '\'' || last == 'o') || (curr == 'o' && last == '\''))
|
||||
if ((curr == '\'' && (last == '\'' || last == 'o')) || (curr == 'o' && last == '\''))
|
||||
throw comp_error(loc_, "invalid octal literal");
|
||||
|
||||
if (curr == '\'')
|
||||
@ -694,7 +696,7 @@ lex_number:
|
||||
if (state == reader::end)
|
||||
break;
|
||||
|
||||
if (curr == '\'' && (last == '\'' || last == 'b') || (curr == 'b' && last == '\''))
|
||||
if ((curr == '\'' && (last == '\'' || last == 'b')) || (curr == 'b' && last == '\''))
|
||||
throw comp_error(loc_, "invalid binary literal");
|
||||
|
||||
if (curr == '\'')
|
||||
@ -728,7 +730,7 @@ lex_number:
|
||||
if (state == reader::end)
|
||||
break;
|
||||
|
||||
if (curr == '\'' && (last == '\'' || last == 'x') || (curr == 'x' && last == '\''))
|
||||
if ((curr == '\'' && (last == '\'' || last == 'x')) || (curr == 'x' && last == '\''))
|
||||
throw comp_error(loc_, "invalid hexadecimal literal");
|
||||
|
||||
if (curr == '\'')
|
||||
|
@ -13,7 +13,7 @@ constexpr size_t max_buf_size = 0x2000;
|
||||
struct buffer
|
||||
{
|
||||
char* data;
|
||||
int length;
|
||||
size_t length;
|
||||
|
||||
buffer();
|
||||
~buffer();
|
||||
@ -32,9 +32,14 @@ struct reader
|
||||
|
||||
reader();
|
||||
|
||||
reader& operator=(const reader& r)
|
||||
reader(const reader& obj)
|
||||
{
|
||||
std::memcpy(this, &r, sizeof(reader));
|
||||
std::memcpy(this, &obj, sizeof(reader));
|
||||
}
|
||||
|
||||
reader& operator=(const reader& obj)
|
||||
{
|
||||
std::memcpy(this, &obj, sizeof(reader));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user