diff options
author | Andrey Bokhanko <andreybokhanko@gmail.com> | 2016-10-19 12:06:10 +0000 |
---|---|---|
committer | Andrey Bokhanko <andreybokhanko@gmail.com> | 2016-10-19 12:06:10 +0000 |
commit | 9941ca8af6b4c39fd0b9e47dc7e593d884b55710 (patch) | |
tree | 78b388f78a84e3437862043cedd7a5324b5ed8fa /clang/lib/Sema/SemaExpr.cpp | |
parent | 7dcb6e572ec7d62cc6744df4452fc7ef80f20c36 (diff) | |
download | bcm5719-llvm-9941ca8af6b4c39fd0b9e47dc7e593d884b55710.tar.gz bcm5719-llvm-9941ca8af6b4c39fd0b9e47dc7e593d884b55710.zip |
[Sema] Gcc compatibility of vector shift
Gcc prints error if elements of left and right parts of a shift have different
sizes. This patch is provided the GCC compatibility.
Patch by Vladimir Yakovlev.
Differential Revision: https://reviews.llvm.org/D24669
llvm-svn: 284579
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 40b5512523f..15564918b37 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8790,6 +8790,16 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); return QualType(); } + if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) { + const BuiltinType *LHSBT = LHSEleType->getAs<clang::BuiltinType>(); + const BuiltinType *RHSBT = RHSEleType->getAs<clang::BuiltinType>(); + if (LHSBT != RHSBT && + S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) { + S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal) + << LHS.get()->getType() << RHS.get()->getType() + << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); + } + } } else { // ...else expand RHS to match the number of elements in LHS. QualType VecTy = |