@@ -10578,10 +10578,13 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
10578
10578
QualType LHSType = LHS.get()->getType().getUnqualifiedType();
10579
10579
QualType RHSType = RHS.get()->getType().getUnqualifiedType();
10580
10580
10581
+ const BuiltinType *LHSBuiltinTy = LHSType->getAs<BuiltinType>();
10582
+ const BuiltinType *RHSBuiltinTy = RHSType->getAs<BuiltinType>();
10583
+
10581
10584
unsigned DiagID = diag::err_typecheck_invalid_operands;
10582
10585
if ((OperationKind == ACK_Arithmetic) &&
10583
- (LHSType->castAs<BuiltinType>() ->isSVEBool() ||
10584
- RHSType->castAs<BuiltinType>() ->isSVEBool())) {
10586
+ ((LHSBuiltinTy && LHSBuiltinTy ->isSVEBool() ) ||
10587
+ (RHSBuiltinTy && RHSBuiltinTy ->isSVEBool() ))) {
10585
10588
Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
10586
10589
<< RHS.get()->getSourceRange();
10587
10590
return QualType();
@@ -10610,12 +10613,33 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
10610
10613
return DestType;
10611
10614
}
10612
10615
10613
- if (RHSType->isVLSTBuiltinType() && !LHSType->isVLSTBuiltinType()) {
10614
- auto DestType = tryScalableVectorConvert((IsCompAssign ? nullptr : &LHS),
10615
- LHSType, RHSType);
10616
- if (DestType == QualType())
10617
- return InvalidOperands(Loc, LHS, RHS);
10618
- return DestType;
10616
+ if ((!LHSType->isVLSTBuiltinType() && !LHSType->isRealType()) ||
10617
+ (!RHSType->isVLSTBuiltinType() && !RHSType->isRealType())) {
10618
+ Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10619
+ << LHSType << RHSType << LHS.get()->getSourceRange()
10620
+ << RHS.get()->getSourceRange();
10621
+ return QualType();
10622
+ }
10623
+
10624
+ if (LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType() &&
10625
+ Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
10626
+ Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
10627
+ Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
10628
+ << LHSType << RHSType << LHS.get()->getSourceRange()
10629
+ << RHS.get()->getSourceRange();
10630
+ return QualType();
10631
+ }
10632
+
10633
+ if (LHSType->isVLSTBuiltinType() || RHSType->isVLSTBuiltinType()) {
10634
+ QualType Scalar = LHSType->isVLSTBuiltinType() ? RHSType : LHSType;
10635
+ QualType Vector = LHSType->isVLSTBuiltinType() ? LHSType : RHSType;
10636
+ bool ScalarOrVector =
10637
+ LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType();
10638
+
10639
+ Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
10640
+ << ScalarOrVector << Scalar << Vector;
10641
+
10642
+ return QualType();
10619
10643
}
10620
10644
10621
10645
Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
0 commit comments