commit c2c10365bbd3f898fe5bf7d579dfb98375123564
parent facfafe9e359d6da38f194b2266743da91026714
Author: Eyal Sawady <ecs@d2evs.net>
Date: Fri, 26 Feb 2021 16:40:11 -0500
don't generate implicit casts on terminating exprs
Fixes `if (true) abort() else true;`
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -43,7 +43,7 @@ expect(const struct location *loc, bool constraint, char *fmt, ...)
static struct expression *
lower_implicit_cast(const struct type *to, struct expression *expr)
{
- if (to == expr->result) {
+ if (to == expr->result || expr->terminates) {
return expr;
}
@@ -58,7 +58,7 @@ lower_implicit_cast(const struct type *to, struct expression *expr)
struct expression *cast = xcalloc(1, sizeof(struct expression));
cast->type = EXPR_CAST;
cast->result = to;
- cast->terminates = expr->terminates;
+ cast->terminates = false;
cast->cast.kind = C_CAST;
cast->cast.value = expr;
return cast;