diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-09-22 13:03:14 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-09-22 13:03:14 +0000 |
commit | 9df05ea69b16e48f2b1cda56c2c341ce77493f4e (patch) | |
tree | 1407b724e2345e74efb32a9ee97057ceaf4194a2 /lib/Sema/SemaExpr.cpp | |
parent | 77b6de07be9186063c12928d2e9785a5d4eecbf6 (diff) |
In OpenCL, conversions between different vector types are disallowed
OpenCL 6.2.1 says: "Implicit conversions between built-in vector data types are
disallowed." OpenCL 6.2.2 says: "Explicit casts between vector types are not
legal." For example:
uint4 u = (uint4)(1);
int4 i = u; // invalid implicit conversion
int4 e = (int4)u; // invalid explicit conversion
Fixes PR10967. Submitted by: Anton Lokhmotov <Anton.lokhmotov@gmail.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 58b6258304..7106ab2d16 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4194,8 +4194,12 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, // If SrcTy is a VectorType, the total size must match to explicitly cast to // an ExtVectorType. + // In OpenCL, casts between vectors of different types are not allowed. + // (See OpenCL 6.2). if (SrcTy->isVectorType()) { - if (Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy)) { + if (Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy) + || (getLangOptions().OpenCL && + (DestTy.getCanonicalType() != SrcTy.getCanonicalType()))) { Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors) << DestTy << SrcTy << R; return ExprError(); |