Fixed codegen with addresses as boolean test conditions.

Fixed warning on unreachable code of if body.
This commit is contained in:
acqn 2021-03-13 14:25:51 +08:00 committed by Oliver Schmidt
parent bbfc24770e
commit f8835d2867
2 changed files with 9 additions and 4 deletions

View File

@ -70,7 +70,7 @@ unsigned Test (unsigned Label, int Invert)
DoDeferred (SQP_KEEP_NONE, &Expr);
/* Result is constant, so we know the outcome */
Result = (Expr.IVal != 0);
Result = (Expr.IVal != 0) ? TESTEXPR_TRUE : TESTEXPR_FALSE;
/* Constant rvalue */
if (!Invert && Expr.IVal == 0) {
@ -86,7 +86,12 @@ unsigned Test (unsigned Label, int Invert)
DoDeferred (SQP_KEEP_NONE, &Expr);
/* Object addresses are non-NULL */
Result = 1;
Result = TESTEXPR_TRUE;
/* Condition is always true */
if (Invert) {
g_jump (Label);
}
} else {

View File

@ -44,9 +44,9 @@
#define TESTEXPR_UNKNOWN 0 /* Result of expression unknown */
#define TESTEXPR_UNKNOWN -1 /* Result of expression unknown */
#define TESTEXPR_TRUE 1 /* Expression yields true */
#define TESTEXPR_FALSE 2 /* Expression yields false */
#define TESTEXPR_FALSE 0 /* Expression yields false */