diff options
author | John McCall <rjmccall@apple.com> | 2013-02-12 01:29:43 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-02-12 01:29:43 +0000 |
commit | 9dd74c5504c743c96ea3a1d691d6a75ec3a98147 (patch) | |
tree | f1121c7876d52867edccb389dcfba07bb3f90526 /lib/Sema/SemaExpr.cpp | |
parent | c2808e705eb8a1a825a5807cabc16d55052c31bd (diff) |
Diagnose loads of 'half' l-values in OpenCL.
Patch by Joey Gouly!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d0aa6973b7..689c1497fd 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -482,6 +482,14 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { if (T->isVoidType()) return Owned(E); + // OpenCL usually rejects direct accesses to values of 'half' type. + if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 && + T->isHalfType()) { + Diag(E->getExprLoc(), diag::err_opencl_half_load_store) + << 0 << T; + return ExprError(); + } + CheckForNullPointerDereference(*this, E); // C++ [conv.lval]p1: @@ -3487,13 +3495,6 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, diag::err_subscript_incomplete_type, BaseExpr)) return ExprError(); - if (ResultType->isHalfType() && getLangOpts().OpenCL && - !getOpenCLOptions().cl_khr_fp16) { - Diag(BaseExpr->getLocStart(), diag::err_opencl_half_subscript) << ResultType - << BaseExpr->getType() << BaseExpr->getSourceRange(); - return ExprError(); - } - assert(VK == VK_RValue || LangOpts.CPlusPlus || !ResultType.isCForbiddenLValueType()); @@ -5663,7 +5664,6 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS, LHSType = Context.getCanonicalType(LHSType).getUnqualifiedType(); RHSType = Context.getCanonicalType(RHSType).getUnqualifiedType(); - // Common case: no conversion required. if (LHSType == RHSType) { Kind = CK_NoOp; @@ -8242,13 +8242,6 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, return QualType(); } - if (Result->isHalfType() && S.getLangOpts().OpenCL && - !S.getOpenCLOptions().cl_khr_fp16) { - S.Diag(OpLoc, diag::err_opencl_half_dereferencing) - << OpTy << Op->getSourceRange(); - return QualType(); - } - // Dereferences are usually l-values... VK = VK_LValue; |