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 | |
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')
-rw-r--r-- | lib/Sema/SemaCast.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 23 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 1 |
3 files changed, 9 insertions, 21 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index d1e95d7df9..e6dc0bd8bc 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -2111,12 +2111,6 @@ void CastOperation::CheckCStyleCast() { 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. 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; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index b257a59c10..109c8e4902 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2642,6 +2642,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, S.Diag(Param->getLocation(), diag::err_opencl_half_argument) << ArgTy; D.setInvalidType(); + Param->setInvalidDecl(); } } else { S.Diag(Param->getLocation(), |