Support lax vector conversions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 336dca7..f53980c 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1100,9 +1100,22 @@
return Compatible;
} else if (lhsType->isArithmeticType() && rhsType->isArithmeticType()) {
if (lhsType->isVectorType() || rhsType->isVectorType()) {
- if (lhsType.getCanonicalType() != rhsType.getCanonicalType())
+ if (!getLangOptions().LaxVectorConversions) {
+ if (lhsType.getCanonicalType() != rhsType.getCanonicalType())
+ return Incompatible;
+ } else {
+ if (lhsType->isVectorType() && rhsType->isVectorType()) {
+ if ((lhsType->isIntegerType() && rhsType->isIntegerType()) ||
+ (lhsType->isRealFloatingType() &&
+ rhsType->isRealFloatingType())) {
+ if (Context.getTypeSize(lhsType, SourceLocation()) ==
+ Context.getTypeSize(rhsType, SourceLocation()))
+ return Compatible;
+ }
+ }
return Incompatible;
- }
+ }
+ }
return Compatible;
} else if (lhsType->isPointerType()) {
if (rhsType->isIntegerType())