expressionsem.d: Combine redundant branches (#20796)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>
This commit is contained in:
Dennis 2025-01-28 15:35:17 +01:00 committed by GitHub
parent c3da7f0747
commit 84c7b040b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12127,10 +12127,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return; return;
} }
if (exp.suggestBinaryOverloads(sc)) if (exp.suggestBinaryOverloads(sc) || exp.checkArithmeticBin())
return setError();
if (exp.checkArithmeticBin())
return setError(); return setError();
tb1 = exp.e1.type.toBasetype(); tb1 = exp.e1.type.toBasetype();
@ -12283,10 +12280,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return; return;
} }
if (exp.suggestBinaryOverloads(sc)) if (exp.suggestBinaryOverloads(sc) || exp.checkArithmeticBin())
return setError();
if (exp.checkArithmeticBin())
return setError(); return setError();
t1 = exp.e1.type.toBasetype(); t1 = exp.e1.type.toBasetype();
@ -12587,7 +12581,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
trySetCatExpLowering(result); trySetCatExpLowering(result);
} }
bool commonBinOpSemantic(BinExp exp) bool commonArithBinOpSemantic(BinExp exp)
{ {
if (Expression e = exp.opOverloadBinary(sc, aliasThisStop)) if (Expression e = exp.opOverloadBinary(sc, aliasThisStop))
{ {
@ -12600,12 +12594,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
result = ex; result = ex;
return true; return true;
} }
return false;
}
bool commonArithBinOpSemantic(BinExp exp)
{
if (commonBinOpSemantic(exp))
return true;
Type tb = exp.type.toBasetype(); Type tb = exp.type.toBasetype();
if (tb.ty == Tarray || tb.ty == Tsarray) if (tb.ty == Tarray || tb.ty == Tsarray)
@ -12619,13 +12607,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return true; return true;
} }
if (exp.suggestBinaryOverloads(sc)) if (exp.suggestBinaryOverloads(sc) || exp.checkArithmeticBin() || exp.checkSharedAccessBin(sc))
{
setError();
return true;
}
if (exp.checkArithmeticBin() || exp.checkSharedAccessBin(sc))
{ {
setError(); setError();
return true; return true;
@ -12839,10 +12821,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return; return;
} }
if (exp.suggestBinaryOverloads(sc)) if (exp.suggestBinaryOverloads(sc) || exp.checkIntegralBin() || exp.checkSharedAccessBin(sc))
return setError();
if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc))
return setError(); return setError();
if (!target.isVectorOpSupported(exp.e1.type.toBasetype(), exp.op, exp.e2.type.toBasetype())) if (!target.isVectorOpSupported(exp.e1.type.toBasetype(), exp.op, exp.e2.type.toBasetype()))
@ -12913,10 +12892,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return; return;
} }
if (exp.suggestBinaryOverloads(sc)) if (exp.suggestBinaryOverloads(sc) || exp.checkIntegralBin() || exp.checkSharedAccessBin(sc))
return setError();
if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc))
return setError(); return setError();
result = exp; result = exp;