diff options
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 66 |
1 files changed, 1 insertions, 65 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 099238d0966..2b4c639dcd8 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7772,67 +7772,6 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, << RHS.get()->getSourceRange(); } -/// \brief Return the resulting type when an OpenCL vector is shifted -/// by a scalar or vector shift amount. -static QualType checkOpenCLVectorShift(Sema &S, - ExprResult &LHS, ExprResult &RHS, - SourceLocation Loc) { - // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector. - if (!LHS.get()->getType()->isVectorType()) { - S.Diag(Loc, diag::err_shift_rhs_only_vector) - << RHS.get()->getType() << LHS.get()->getType() - << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); - return QualType(); - } - - LHS = S.UsualUnaryConversions(LHS.get()); - if (LHS.isInvalid()) return QualType(); - - RHS = S.UsualUnaryConversions(RHS.get()); - if (RHS.isInvalid()) return QualType(); - - QualType LHSType = LHS.get()->getType(); - const VectorType *LHSVecTy = LHSType->getAs<VectorType>(); - QualType LHSEleType = LHSVecTy->getElementType(); - - // Note that RHS might not be a vector. - QualType RHSType = RHS.get()->getType(); - const VectorType *RHSVecTy = RHSType->getAs<VectorType>(); - QualType RHSEleType = RHSVecTy ? RHSVecTy->getElementType() : RHSType; - - // OpenCL v1.1 s6.3.j says that the operands need to be integers. - if (!LHSEleType->isIntegerType()) { - S.Diag(Loc, diag::err_typecheck_expect_int) - << LHS.get()->getType() << LHS.get()->getSourceRange(); - return QualType(); - } - - if (!RHSEleType->isIntegerType()) { - S.Diag(Loc, diag::err_typecheck_expect_int) - << RHS.get()->getType() << RHS.get()->getSourceRange(); - return QualType(); - } - - if (RHSVecTy) { - // OpenCL v1.1 s6.3.j says that for vector types, the operators - // are applied component-wise. So if RHS is a vector, then ensure - // that the number of elements is the same as LHS... - if (RHSVecTy->getNumElements() != LHSVecTy->getNumElements()) { - S.Diag(Loc, diag::err_typecheck_vector_lengths_not_equal) - << LHS.get()->getType() << RHS.get()->getType() - << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); - return QualType(); - } - } else { - // ...else expand RHS to match the number of elements in LHS. - QualType VecTy = - S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements()); - RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat); - } - - return LHSType; -} - // C99 6.5.7 QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, @@ -7841,11 +7780,8 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, // Vector shifts promote their scalar inputs to vector type. if (LHS.get()->getType()->isVectorType() || - RHS.get()->getType()->isVectorType()) { - if (LangOpts.OpenCL) - return checkOpenCLVectorShift(*this, LHS, RHS, Loc); + RHS.get()->getType()->isVectorType()) return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign); - } // Shifts don't perform usual arithmetic conversions, they just do integer // promotions on each operand. C99 6.5.7p3 |