diff options
author | Joey Gouly <joey.gouly@gmail.com> | 2014-01-14 12:47:29 +0000 |
---|---|---|
committer | Joey Gouly <joey.gouly@gmail.com> | 2014-01-14 12:47:29 +0000 |
commit | 8fc32f01dc5dcdf55152c7daac4e8c4cb511ccdb (patch) | |
tree | 77edcc72c05fc0a83194a915fe6c7d6960ea1fb2 /clang/lib/Sema/SemaCast.cpp | |
parent | 9d2e0df0493e4085c556abf5c5433ca06f43008d (diff) | |
download | bcm5719-llvm-8fc32f01dc5dcdf55152c7daac4e8c4cb511ccdb.tar.gz bcm5719-llvm-8fc32f01dc5dcdf55152c7daac4e8c4cb511ccdb.zip |
[OpenCL] Disallow casts between address spaces.
llvm-svn: 199208
Diffstat (limited to 'clang/lib/Sema/SemaCast.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 86621255609..ef229cf838b 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -2170,6 +2170,21 @@ void CastOperation::CheckCStyleCast() { assert(!SrcType->isPlaceholderType()); + // OpenCL v1 s6.5: Casting a pointer to address space A to a pointer to + // address space B is illegal. + if (Self.getLangOpts().OpenCL && DestType->isPointerType() && + SrcType->isPointerType()) { + if (DestType->getPointeeType().getAddressSpace() != + SrcType->getPointeeType().getAddressSpace()) { + Self.Diag(OpRange.getBegin(), + diag::err_typecheck_incompatible_address_space) + << SrcType << DestType << Sema::AA_Casting + << SrcExpr.get()->getSourceRange(); + SrcExpr = ExprError(); + return; + } + } + if (Self.RequireCompleteType(OpRange.getBegin(), DestType, diag::err_typecheck_cast_to_incomplete)) { SrcExpr = ExprError(); |