summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 65d23418631..3619834fce6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7394,6 +7394,22 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS,
return IncompatibleVectors;
}
}
+
+ // When the RHS comes from another lax conversion (e.g. binops between
+ // scalars and vectors) the result is canonicalized as a vector. When the
+ // LHS is also a vector, the lax is allowed by the condition above. Handle
+ // the case where LHS is a scalar.
+ if (LHSType->isScalarType()) {
+ const VectorType *VecType = RHSType->getAs<VectorType>();
+ if (VecType && VecType->getNumElements() == 1 &&
+ isLaxVectorConversion(RHSType, LHSType)) {
+ ExprResult *VecExpr = &RHS;
+ *VecExpr = ImpCastExprToType(VecExpr->get(), LHSType, CK_BitCast);
+ Kind = CK_BitCast;
+ return Compatible;
+ }
+ }
+
return Incompatible;
}
OpenPOWER on IntegriCloud