mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
Fixes for some minor bugs clang-analyzer and cppcheck found
Signed-off-by: Dale Weiler <killfieldengine@gmail.com>
This commit is contained in:
parent
8cd94192d8
commit
acf4da9385
5 changed files with 17 additions and 16 deletions
2
ast.c
2
ast.c
|
@ -2152,7 +2152,7 @@ bool ast_ifthen_codegen(ast_ifthen *self, ast_function *func, bool lvalue, ir_va
|
|||
ir_value *condval;
|
||||
ir_value *dummy;
|
||||
|
||||
ir_block *cond = func->curblock;
|
||||
ir_block *cond;
|
||||
ir_block *ontrue;
|
||||
ir_block *onfalse;
|
||||
ir_block *ontrue_endblock = NULL;
|
||||
|
|
2
gmqcc.h
2
gmqcc.h
|
@ -116,7 +116,7 @@
|
|||
* I suspect it also has just __inline of some sort, but our use
|
||||
* of inline is correct (not guessed), WE WANT IT TO BE INLINE
|
||||
*/
|
||||
#elseif defined(_MSC_VER)
|
||||
#elif defined(_MSC_VER)
|
||||
# define GMQCC_INLINE __forceinline
|
||||
#else
|
||||
# define GMQCC_INLINE
|
||||
|
|
12
ir.c
12
ir.c
|
@ -1357,9 +1357,6 @@ bool ir_block_create_store_op(ir_block *self, lex_ctx ctx, int op, ir_value *tar
|
|||
irerror(self->context, "unreachable statement (%s)", self->label);
|
||||
return false;
|
||||
}
|
||||
in = ir_instr_new(ctx, self, op);
|
||||
if (!in)
|
||||
return false;
|
||||
|
||||
if (target->store == store_value &&
|
||||
(op < INSTR_STOREP_F || op > INSTR_STOREP_FNC))
|
||||
|
@ -1370,9 +1367,14 @@ bool ir_block_create_store_op(ir_block *self, lex_ctx ctx, int op, ir_value *tar
|
|||
return false;
|
||||
}
|
||||
|
||||
in = ir_instr_new(ctx, self, op);
|
||||
if (!in)
|
||||
return false;
|
||||
|
||||
if (!ir_instr_op(in, 0, target, true) ||
|
||||
!ir_instr_op(in, 1, what, false))
|
||||
{
|
||||
ir_instr_delete(in);
|
||||
return false;
|
||||
}
|
||||
vec_push(self->instr, in);
|
||||
|
@ -1439,8 +1441,10 @@ bool ir_block_create_return(ir_block *self, lex_ctx ctx, ir_value *v)
|
|||
if (!in)
|
||||
return false;
|
||||
|
||||
if (v && !ir_instr_op(in, 0, v, false))
|
||||
if (v && !ir_instr_op(in, 0, v, false)) {
|
||||
ir_instr_delete(in);
|
||||
return false;
|
||||
}
|
||||
|
||||
vec_push(self->instr, in);
|
||||
return true;
|
||||
|
|
1
lexer.c
1
lexer.c
|
@ -1061,7 +1061,6 @@ int lex_do(lex_file *lex)
|
|||
if (rc < 0)
|
||||
return (lex->tok.ttype = TOKEN_FATAL);
|
||||
|
||||
v = lex->tok.value;
|
||||
if (lex->modelname) {
|
||||
frame_macro m;
|
||||
m.value = lex->framevalue;
|
||||
|
|
16
parser.c
16
parser.c
|
@ -1275,9 +1275,9 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
|||
fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
|
||||
else
|
||||
parseerror(parser, "too %s parameters for function call: expected %i, got %i\n"
|
||||
" -> `%s` has been declared here: %s:%i",
|
||||
fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount,
|
||||
fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
|
||||
" -> it has been declared here: %s:%i",
|
||||
fewmany, (int)vec_size(fun->expression.params), (int)paramcount,
|
||||
ast_ctx(fun).file, (int)ast_ctx(fun).line);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -1291,9 +1291,9 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
|||
else
|
||||
return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
|
||||
"too %s parameters for function call: expected %i, got %i\n"
|
||||
" -> `%s` has been declared here: %s:%i",
|
||||
fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount,
|
||||
fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
|
||||
" -> it has been declared here: %s:%i",
|
||||
fewmany, (int)vec_size(fun->expression.params), (int)paramcount,
|
||||
ast_ctx(fun).file, (int)ast_ctx(fun).line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1698,7 +1698,6 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
|
|||
vec_push(sy.ops, syparen(parser_ctx(parser), SY_PAREN_INDEX, 0));
|
||||
wantop = false;
|
||||
} else if (op->id == opid2('?',':')) {
|
||||
wantop = false;
|
||||
vec_push(sy.ops, syop(parser_ctx(parser), op));
|
||||
vec_push(sy.ops, syparen(parser_ctx(parser), SY_PAREN_TERNARY, 0));
|
||||
wantop = false;
|
||||
|
@ -2339,8 +2338,7 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou
|
|||
return false;
|
||||
}
|
||||
if (!OPTS_FLAG(RELAXED_SWITCH)) {
|
||||
opval = (ast_value*)swcase.value;
|
||||
if (!ast_istype(swcase.value, ast_value)) { /* || opval->cvq != CV_CONST) { */
|
||||
if (!ast_istype(swcase.value, ast_value)) { /* || ((ast_value*)swcase.value)->cvq != CV_CONST) { */
|
||||
parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch");
|
||||
ast_unref(operand);
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue