diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-03-11 16:23:10 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-03-11 16:23:10 +0000 |
commit | 7263c35440b28f6b06c0e163b10b9f460a3d37ae (patch) | |
tree | 30b3a18ee14248473582f0993226db4134c89360 /clang/lib/Sema/SemaExpr.cpp | |
parent | 072f93fe7256e407d6de0ce799cb7bc596b4328a (diff) | |
download | bcm5719-llvm-7263c35440b28f6b06c0e163b10b9f460a3d37ae.tar.gz bcm5719-llvm-7263c35440b28f6b06c0e163b10b9f460a3d37ae.zip |
OpenCL: CL2.0 atomic type diagnostics
Added restictions for atomic type usage from OpenCL C Spec Section 6.13.11.8
llvm-svn: 231935
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index a793d45da4e..9b0ccc9458a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -9747,6 +9747,19 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, return ExprError(); } + if (getLangOpts().OpenCL) { + // OpenCLC v2.0 s6.13.11.8 forbids operations on atomic types. + if (LHSExpr->getType()->isAtomicType() || + RHSExpr->getType()->isAtomicType()) { + SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd()); + if (Opc == BO_Assign) + Diag(OpLoc, diag::err_atomic_assignment) << SR; + else + ResultTy = InvalidOperands(OpLoc, LHS, RHS); + return ExprError(); + } + } + switch (Opc) { case BO_Assign: ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType()); @@ -10219,6 +10232,15 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, ExprValueKind VK = VK_RValue; ExprObjectKind OK = OK_Ordinary; QualType resultType; + if (getLangOpts().OpenCL) { + // OpenCLC v2.0 s6.13.11.8, the only legal unary operation. + // for atomics is '&'. + if (Opc != UO_AddrOf && InputExpr->getType()->isAtomicType()) { + return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) + << InputExpr->getType() + << Input.get()->getSourceRange()); + } + } switch (Opc) { case UO_PreInc: case UO_PreDec: |