mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
-fperl-logic now doesn't allow logic ops with operands of different types, but therefore uses the correct output type
This commit is contained in:
parent
9b9fbb6e3b
commit
2a61a65ce0
2 changed files with 15 additions and 2 deletions
9
ast.c
9
ast.c
|
@ -397,8 +397,13 @@ ast_binary* ast_binary_new(lex_ctx ctx, int op,
|
|||
|
||||
if (op >= INSTR_EQ_F && op <= INSTR_GT)
|
||||
self->expression.vtype = TYPE_FLOAT;
|
||||
else if (op == INSTR_AND || op == INSTR_OR ||
|
||||
op == INSTR_BITAND || op == INSTR_BITOR)
|
||||
else if (op == INSTR_AND || op == INSTR_OR) {
|
||||
if (OPTS_FLAG(PERL_LOGIC))
|
||||
ast_type_adopt(self, right);
|
||||
else
|
||||
self->expression.vtype = TYPE_FLOAT;
|
||||
}
|
||||
else if (op == INSTR_BITAND || op == INSTR_BITOR)
|
||||
self->expression.vtype = TYPE_FLOAT;
|
||||
else if (op == INSTR_MUL_VF || op == INSTR_MUL_FV)
|
||||
self->expression.vtype = TYPE_VECTOR;
|
||||
|
|
8
parser.c
8
parser.c
|
@ -841,7 +841,15 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
|
|||
out = (ast_expression*)parser_const_float(parser,
|
||||
(generated_op == INSTR_OR ? (ConstF(0) || ConstF(1)) : (ConstF(0) && ConstF(1))));
|
||||
else
|
||||
{
|
||||
if (OPTS_FLAG(PERL_LOGIC) && !ast_compare_type(exprs[0], exprs[1])) {
|
||||
ast_type_to_string(exprs[0], ty1, sizeof(ty1));
|
||||
ast_type_to_string(exprs[1], ty2, sizeof(ty2));
|
||||
parseerror(parser, "invalid types for logical operation with -fperl-logic: %s and %s", ty1, ty2);
|
||||
return false;
|
||||
}
|
||||
out = (ast_expression*)ast_binary_new(ctx, generated_op, exprs[0], exprs[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
case opid2('?',':'):
|
||||
|
|
Loading…
Reference in a new issue