diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 0e6bc114709d..75a07a747f34 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -13086,9 +13086,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return; } - override void visit(ShlExp exp) + private void visitShift(BinExp exp) { - //printf("ShlExp::semantic(), type = %p\n", type); if (exp.type) { result = exp; @@ -13123,79 +13122,20 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exp; } + override void visit(ShlExp exp) + { + visitShift(exp); + } override void visit(ShrExp exp) { - if (exp.type) - { - result = exp; - return; - } - - if (Expression ex = binSemanticProp(exp, sc)) - { - result = ex; - return; - } - Expression e = exp.op_overload(sc); - if (e) - { - result = e; - return; - } - - if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc)) - return setError(); - - if (!target.isVectorOpSupported(exp.e1.type.toBasetype(), exp.op, exp.e2.type.toBasetype())) - { - result = exp.incompatibleTypes(); - return; - } - exp.e1 = integralPromotions(exp.e1, sc); - if (exp.e2.type.toBasetype().ty != Tvector) - exp.e2 = exp.e2.castTo(sc, Type.tshiftcnt); - - exp.type = exp.e1.type; - result = exp; + visitShift(exp); } - override void visit(UshrExp exp) { - if (exp.type) - { - result = exp; - return; - } - - if (Expression ex = binSemanticProp(exp, sc)) - { - result = ex; - return; - } - Expression e = exp.op_overload(sc); - if (e) - { - result = e; - return; - } - - if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc)) - return setError(); - - if (!target.isVectorOpSupported(exp.e1.type.toBasetype(), exp.op, exp.e2.type.toBasetype())) - { - result = exp.incompatibleTypes(); - return; - } - exp.e1 = integralPromotions(exp.e1, sc); - if (exp.e2.type.toBasetype().ty != Tvector) - exp.e2 = exp.e2.castTo(sc, Type.tshiftcnt); - - exp.type = exp.e1.type; - result = exp; + visitShift(exp); } - override void visit(AndExp exp) + private void visitBinaryBitOp(BinExp exp) { if (exp.type) { @@ -13250,114 +13190,17 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exp; } + override void visit(AndExp exp) + { + visitBinaryBitOp(exp); + } override void visit(OrExp exp) { - if (exp.type) - { - result = exp; - return; - } - - if (Expression ex = binSemanticProp(exp, sc)) - { - result = ex; - return; - } - Expression e = exp.op_overload(sc); - if (e) - { - result = e; - return; - } - - if (exp.e1.type.toBasetype().ty == Tbool && exp.e2.type.toBasetype().ty == Tbool) - { - exp.type = exp.e1.type; - result = exp; - return; - } - - if (Expression ex = typeCombine(exp, sc)) - { - result = ex; - return; - } - - Type tb = exp.type.toBasetype(); - if (tb.ty == Tarray || tb.ty == Tsarray) - { - if (!isArrayOpValid(exp)) - { - result = arrayOpInvalidError(exp); - return; - } - result = exp; - return; - } - if (!target.isVectorOpSupported(tb, exp.op, exp.e2.type.toBasetype())) - { - result = exp.incompatibleTypes(); - return; - } - if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc)) - return setError(); - - result = exp; + visitBinaryBitOp(exp); } - override void visit(XorExp exp) { - if (exp.type) - { - result = exp; - return; - } - - if (Expression ex = binSemanticProp(exp, sc)) - { - result = ex; - return; - } - Expression e = exp.op_overload(sc); - if (e) - { - result = e; - return; - } - - if (exp.e1.type.toBasetype().ty == Tbool && exp.e2.type.toBasetype().ty == Tbool) - { - exp.type = exp.e1.type; - result = exp; - return; - } - - if (Expression ex = typeCombine(exp, sc)) - { - result = ex; - return; - } - - Type tb = exp.type.toBasetype(); - if (tb.ty == Tarray || tb.ty == Tsarray) - { - if (!isArrayOpValid(exp)) - { - result = arrayOpInvalidError(exp); - return; - } - result = exp; - return; - } - if (!target.isVectorOpSupported(tb, exp.op, exp.e2.type.toBasetype())) - { - result = exp.incompatibleTypes(); - return; - } - if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc)) - return setError(); - - result = exp; + visitBinaryBitOp(exp); } override void visit(LogicalExp exp)