summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2016-09-19 14:54:41 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2016-09-19 14:54:41 +0000
commit6aaa01b58e0fe1d78242426273b3840e71bce569 (patch)
treedb8d132866e8e708fdc73270cb3b95ba0cf84eec /clang/lib/Sema/SemaExpr.cpp
parent2828b9be1ecf34cbe9ad4df68560131f619edaed (diff)
downloadbcm5719-llvm-6aaa01b58e0fe1d78242426273b3840e71bce569.tar.gz
bcm5719-llvm-6aaa01b58e0fe1d78242426273b3840e71bce569.zip
[OpenCL] Diagnose assignment to dereference of half type pointer
Differential Revision: https://reviews.llvm.org/D24626 llvm-svn: 281904
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 72a35866ad6..f34263dba51 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10100,6 +10100,16 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
QualType LHSType = LHSExpr->getType();
QualType RHSType = CompoundType.isNull() ? RHS.get()->getType() :
CompoundType;
+ // OpenCL v1.2 s6.1.1.1 p2:
+ // The half data type can only be used to declare a pointer to a buffer that
+ // contains half values
+ if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 &&
+ LHSType->isHalfType()) {
+ Diag(Loc, diag::err_opencl_half_load_store) << 1
+ << LHSType.getUnqualifiedType();
+ return QualType();
+ }
+
AssignConvertType ConvTy;
if (CompoundType.isNull()) {
Expr *RHSCheck = RHS.get();
OpenPOWER on IntegriCloud