summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaCast.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-01-23 11:56:20 +0000
committerJoey Gouly <joey.gouly@arm.com>2013-01-23 11:56:20 +0000
commit19dbb20ac4371fae3190379a7e7bd467af3c00aa (patch)
tree4ad0ff118896e57acd79d0f76e8a57311af4bd19 /lib/Sema/SemaCast.cpp
parent218b6dfaee321cec558e15d47b68155dd9f35684 (diff)
Add a new LangOpt NativeHalfType. This option allows for native half/fp16
operations (as opposed to storage only half/fp16). Also add some semantic checks for OpenCL half types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCast.cpp')
-rw-r--r--lib/Sema/SemaCast.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp
index 676db464b6..d1e95d7df9 100644
--- a/lib/Sema/SemaCast.cpp
+++ b/lib/Sema/SemaCast.cpp
@@ -2104,6 +2104,21 @@ void CastOperation::CheckCStyleCast() {
}
}
+ if (Self.getLangOpts().OpenCL && !Self.getOpenCLOptions().cl_khr_fp16) {
+ if (DestType->isHalfType()) {
+ Self.Diag(SrcExpr.get()->getLocStart(), diag::err_opencl_cast_to_half)
+ << DestType << SrcExpr.get()->getSourceRange();
+ SrcExpr = ExprError();
+ return;
+ }
+ if (SrcExpr.get()->getType()->isHalfType()) {
+ Self.Diag(SrcExpr.get()->getLocStart(), diag::err_opencl_cast_from_half)
+ << SrcType << SrcExpr.get()->getSourceRange();
+ SrcExpr = ExprError();
+ return;
+ }
+ }
+
// ARC imposes extra restrictions on casts.
if (Self.getLangOpts().ObjCAutoRefCount) {
checkObjCARCConversion(Sema::CCK_CStyleCast);