def err_attribute_size_too_large : Error<"vector size too large">;
def err_typecheck_vector_not_convertable : Error<
"can't convert between vector values of different size (%0 and %1)">;
+def err_typecheck_vector_not_convertable_non_scalar : Error<
+ "can't convert between vector and non-scalar values (%0 and %1)">;
def err_ext_vector_component_exceeds_length : Error<
"vector component access exceeds type %0">;
def err_ext_vector_component_name_illegal : Error<
if (!Ctx.getLangOpts().LaxVectorConversions)
return false;
+ if (!LHSType->isVectorType() || !RHSType->isVectorType())
+ return false;
+
unsigned LHSSize = Ctx.getTypeSize(LHSType);
unsigned RHSSize = Ctx.getTypeSize(RHSType);
if (LHSSize != RHSSize)
// Make sure such width is the same between the types, otherwise we may end
// up with an invalid bitcast.
unsigned LHSIRSize, RHSIRSize;
- if (LHSType->isVectorType()) {
- const VectorType *Vec = LHSType->getAs<VectorType>();
- LHSIRSize = Vec->getNumElements() *
- Ctx.getTypeSize(Vec->getElementType());
- } else {
- LHSIRSize = LHSSize;
- }
- if (RHSType->isVectorType()) {
- const VectorType *Vec = RHSType->getAs<VectorType>();
- RHSIRSize = Vec->getNumElements() *
- Ctx.getTypeSize(Vec->getElementType());
- } else {
- RHSIRSize = RHSSize;
- }
+ const VectorType *LVec = LHSType->getAs<VectorType>();
+ LHSIRSize = LVec->getNumElements() *
+ Ctx.getTypeSize(LVec->getElementType());
+ const VectorType *RVec = RHSType->getAs<VectorType>();
+ RHSIRSize = RVec->getNumElements() *
+ Ctx.getTypeSize(RVec->getElementType());
+
if (LHSIRSize != RHSIRSize)
return false;
return LHSType;
}
+ if (!(LHSType->isVectorType() || LHSType->isScalarType()) ||
+ !(RHSType->isVectorType() || RHSType->isScalarType())) {
+ Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
+ << LHS.get()->getType() << RHS.get()->getType()
+ << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+ return QualType();
+ }
+
// Canonicalize the ExtVector to the LHS, remember if we swapped so we can
// swap back (so that we don't reverse the inputs to a subtract, for instance.
bool swapped = false;