return false;
}
- if (sy->ops[vec_size(sy->ops)-1].paren) {
+ if (vec_last(sy->ops).paren) {
parseerror(parser, "unmatched parenthesis");
return false;
}
- op = &operators[sy->ops[vec_size(sy->ops)-1].etype - 1];
- ctx = sy->ops[vec_size(sy->ops)-1].ctx;
+ op = &operators[vec_last(sy->ops).etype - 1];
+ ctx = vec_last(sy->ops).ctx;
DEBUGSHUNTDO(con_out("apply %s\n", op->op));
break;
case opid2('?',':'):
+ if (exprs[1]->expression.vtype != exprs[2]->expression.vtype) {
+ ast_type_to_string(exprs[1], ty1, sizeof(ty1));
+ ast_type_to_string(exprs[2], ty2, sizeof(ty2));
+ parseerror(parser, "iperands of ternary expression must have the same type, got %s and %s", ty1, ty2);
+ return false;
+ }
if (CanConstFold1(exprs[0]))
out = (ConstF(0) ? exprs[1] : exprs[2]);
else
}
/* a colon without a pervious question mark cannot be a ternary */
- if (op->id == opid2(':','?')) {
+ if (!ternaries && op->id == opid2(':','?')) {
parser->tok = ':';
break;
}
ir_builder_delete(ir);
return false;
}
+ }
+ if (opts_dump)
+ ir_builder_dump(ir, con_out);
+ for (i = 0; i < vec_size(parser->functions); ++i) {
if (!ir_function_finalize(parser->functions[i]->ir_func)) {
con_out("failed to finalize function %s\n", parser->functions[i]->name);
ir_builder_delete(ir);
}
if (retval) {
- if (opts_dump)
+ if (opts_dumpfin)
ir_builder_dump(ir, con_out);
generate_checksum(parser);