mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 09:02:08 +00:00
[qfcc] Check for unused operands in evaluate_constexpr
Fixes a segfault when evaluating unary expressions on constants.
This commit is contained in:
parent
3d488354b7
commit
c99f8a8df4
1 changed files with 6 additions and 3 deletions
|
@ -204,6 +204,9 @@ get_temp_def (operand_t *op)
|
||||||
static def_t *
|
static def_t *
|
||||||
get_def (operand_t *op)
|
get_def (operand_t *op)
|
||||||
{
|
{
|
||||||
|
if (!op) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if (is_short (op->type)) {
|
if (is_short (op->type)) {
|
||||||
auto def = new_def (0, &type_short, 0, sc_extern);
|
auto def = new_def (0, &type_short, 0, sc_extern);
|
||||||
def->offset = op->value->short_val;
|
def->offset = op->value->short_val;
|
||||||
|
@ -283,9 +286,9 @@ evaluate_constexpr (const expr_t *e)
|
||||||
auto ds = codespace_newstatement (&value_codespace);
|
auto ds = codespace_newstatement (&value_codespace);
|
||||||
*ds = (dstatement_t) {
|
*ds = (dstatement_t) {
|
||||||
.op = opcode_get (inst),
|
.op = opcode_get (inst),
|
||||||
.a = opa->offset,
|
.a = opa ? opa->offset : 0,
|
||||||
.b = opb->offset,
|
.b = opb ? opb->offset : 0,
|
||||||
.c = opc->offset,
|
.c = opc ? opc->offset : 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
options.code.progsversion = saved_version;
|
options.code.progsversion = saved_version;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue