@@ -10464,15 +10464,17 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
10464
10464
}
10465
10465
10466
10466
QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
10467
- SourceLocation Loc) {
10467
+ SourceLocation Loc,
10468
+ ArithConvKind OperationKind) {
10468
10469
QualType LHSType = LHS.get()->getType().getUnqualifiedType();
10469
10470
QualType RHSType = RHS.get()->getType().getUnqualifiedType();
10470
10471
10471
10472
const BuiltinType *LHSVecType = LHSType->getAs<BuiltinType>();
10472
10473
const BuiltinType *RHSVecType = RHSType->getAs<BuiltinType>();
10473
10474
10474
10475
unsigned DiagID = diag::err_typecheck_invalid_operands;
10475
- if (LHSVecType->isSVEBool() || RHSVecType->isSVEBool()) {
10476
+ if ((OperationKind == ACK_Arithmetic) &&
10477
+ (LHSVecType->isSVEBool() || RHSVecType->isSVEBool())) {
10476
10478
Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
10477
10479
<< RHS.get()->getSourceRange();
10478
10480
return QualType();
@@ -10600,7 +10602,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
10600
10602
/*AllowBooleanOperation*/ false,
10601
10603
/*ReportInvalid*/ true);
10602
10604
if (LHSTy->isVLSTBuiltinType() || RHSTy->isVLSTBuiltinType())
10603
- return CheckSizelessVectorOperands(LHS, RHS, Loc);
10605
+ return CheckSizelessVectorOperands(LHS, RHS, Loc, ACK_Arithmetic );
10604
10606
if (!IsDiv &&
10605
10607
(LHSTy->isConstantMatrixType() || RHSTy->isConstantMatrixType()))
10606
10608
return CheckMatrixMultiplyOperands(LHS, RHS, Loc, IsCompAssign);
@@ -10650,7 +10652,7 @@ QualType Sema::CheckRemainderOperands(
10650
10652
->getType()
10651
10653
->getSveEltType(Context)
10652
10654
->hasIntegerRepresentation())
10653
- return CheckSizelessVectorOperands(LHS, RHS, Loc);
10655
+ return CheckSizelessVectorOperands(LHS, RHS, Loc, ACK_Arithmetic );
10654
10656
10655
10657
return InvalidOperands(Loc, LHS, RHS);
10656
10658
}
@@ -10964,7 +10966,8 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
10964
10966
10965
10967
if (LHS.get()->getType()->isVLSTBuiltinType() ||
10966
10968
RHS.get()->getType()->isVLSTBuiltinType()) {
10967
- QualType compType = CheckSizelessVectorOperands(LHS, RHS, Loc);
10969
+ QualType compType =
10970
+ CheckSizelessVectorOperands(LHS, RHS, Loc, ACK_Arithmetic);
10968
10971
if (CompLHSTy)
10969
10972
*CompLHSTy = compType;
10970
10973
return compType;
@@ -11078,7 +11081,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
11078
11081
11079
11082
if (LHS.get()->getType()->isVLSTBuiltinType() ||
11080
11083
RHS.get()->getType()->isVLSTBuiltinType()) {
11081
- QualType compType = CheckSizelessVectorOperands(LHS, RHS, Loc);
11084
+ QualType compType =
11085
+ CheckSizelessVectorOperands(LHS, RHS, Loc, ACK_Arithmetic);
11082
11086
if (CompLHSTy)
11083
11087
*CompLHSTy = compType;
11084
11088
return compType;
@@ -11417,6 +11421,10 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
11417
11421
return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
11418
11422
}
11419
11423
11424
+ if (LHS.get()->getType()->isVLSTBuiltinType() ||
11425
+ RHS.get()->getType()->isVLSTBuiltinType())
11426
+ return InvalidOperands(Loc, LHS, RHS);
11427
+
11420
11428
// Shifts don't perform usual arithmetic conversions, they just do integer
11421
11429
// promotions on each operand. C99 6.5.7p3
11422
11430
@@ -12885,6 +12893,14 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS,
12885
12893
return InvalidOperands(Loc, LHS, RHS);
12886
12894
}
12887
12895
12896
+ if (LHS.get()->getType()->isVLSTBuiltinType() ||
12897
+ RHS.get()->getType()->isVLSTBuiltinType()) {
12898
+ if (LHS.get()->getType()->hasIntegerRepresentation() &&
12899
+ RHS.get()->getType()->hasIntegerRepresentation())
12900
+ return CheckSizelessVectorOperands(LHS, RHS, Loc, ACK_BitwiseOp);
12901
+ return InvalidOperands(Loc, LHS, RHS);
12902
+ }
12903
+
12888
12904
if (Opc == BO_And)
12889
12905
diagnoseLogicalNotOnLHSofCheck(*this, LHS, RHS, Loc, Opc);
12890
12906
0 commit comments