summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-04-14 21:03:38 +0000
committerReid Kleckner <rnk@google.com>2016-04-14 21:03:38 +0000
commite1a16467a305678a51b94cc1047b7635d5f41631 (patch)
treede43446b932bb7e6571b085ef3ce94577e80ace7 /clang/lib/Sema/SemaExpr.cpp
parentf1e7ff9d0e296e7612e045ec43d9c6342bf5ad9b (diff)
downloadbcm5719-llvm-e1a16467a305678a51b94cc1047b7635d5f41631.tar.gz
bcm5719-llvm-e1a16467a305678a51b94cc1047b7635d5f41631.zip
In vector comparisons, handle scalar LHS just as we handle scalar RHS
Summary: Fixes PR27258 Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19123 llvm-svn: 266366
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