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.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fcc608fa1f5..bd56596446e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7929,14 +7929,16 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
return RHSType;
}
- // If we're allowing lax vector conversions, only the total (data) size
- // needs to be the same.
- // FIXME: Should we really be allowing this?
- // FIXME: We really just pick the LHS type arbitrarily?
- if (isLaxVectorConversion(RHSType, LHSType)) {
- QualType resultType = LHSType;
- RHS = ImpCastExprToType(RHS.get(), resultType, CK_BitCast);
- return resultType;
+ // If we're allowing lax vector conversions, only the total (data) size needs
+ // to be the same. If one of the types is scalar, the result is always the
+ // vector type. Don't allow this if the scalar operand is an lvalue.
+ QualType VecType = LHSVecType ? LHSType : RHSType;
+ QualType ScalarType = LHSVecType ? RHSType : LHSType;
+ ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS;
+ if (isLaxVectorConversion(ScalarType, VecType) &&
+ !ScalarExpr->get()->isLValue()) {
+ *ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
+ return VecType;
}
// Okay, the expression is invalid.
@@ -9480,7 +9482,7 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
}
// Return a signed type for the vector.
- return GetSignedVectorType(LHSType);
+ return GetSignedVectorType(vType);
}
QualType Sema::CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
OpenPOWER on IntegriCloud