Ternary fix for some obscure cases.

This commit is contained in:
acqn 2021-03-14 02:39:40 +08:00 committed by Oliver Schmidt
parent 7d528d9eb0
commit a51d6d40de

View file

@ -3987,8 +3987,9 @@ static void hieQuest (ExprDesc* Expr)
*/
ExprWithCheck (hie1, &Expr2);
Expr2IsNULL = ED_IsNullPtr (&Expr2);
if (!IsTypeVoid (Expr2.Type)) {
if (!ConstantCond || !ED_IsConst (&Expr2)) {
if (!IsTypeVoid (Expr2.Type) &&
ED_YetToLoad (&Expr2) &&
(!ConstantCond || !ED_IsConst (&Expr2))) {
/* Load it into the primary */
LoadExpr (CF_NONE, &Expr2);
@ -4004,7 +4005,6 @@ static void hieQuest (ExprDesc* Expr)
DoDeferred (SQP_KEEP_NONE, &Expr2);
}
Expr2.Type = PtrConversion (Expr2.Type);
}
if (!ConstantCond) {
/* Remember the current code position */
@ -4021,6 +4021,9 @@ static void hieQuest (ExprDesc* Expr)
g_defcodelabel (FalseLab);
} else {
if (Expr->IVal == 0) {
/* Expr2 is unevaluated when the condition is false */
Expr2.Flags |= E_EVAL_UNEVAL;
/* Remove the load code of Expr2 */
RemoveCode (&SkippedBranch);
} else {
@ -4035,8 +4038,9 @@ static void hieQuest (ExprDesc* Expr)
*/
ExprWithCheck (hie1, &Expr3);
Expr3IsNULL = ED_IsNullPtr (&Expr3);
if (!IsTypeVoid (Expr3.Type)) {
if (!ConstantCond || !ED_IsConst (&Expr3)) {
if (!IsTypeVoid (Expr3.Type) &&
ED_YetToLoad (&Expr3) &&
(!ConstantCond || !ED_IsConst (&Expr3))) {
/* Load it into the primary */
LoadExpr (CF_NONE, &Expr3);
@ -4052,9 +4056,11 @@ static void hieQuest (ExprDesc* Expr)
DoDeferred (SQP_KEEP_NONE, &Expr3);
}
Expr3.Type = PtrConversion (Expr3.Type);
}
if (ConstantCond && Expr->IVal != 0) {
/* Expr3 is unevaluated when the condition is true */
Expr3.Flags |= E_EVAL_UNEVAL;
/* Remove the load code of Expr3 */
RemoveCode (&SkippedBranch);
}