Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 45f7cae..7c31be6 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4483,6 +4483,14 @@
SCAsWritten = SC_OpenCLWorkGroupLocal;
}
+ // OpenCL v1.2 s6.9.b p4:
+ // The sampler type cannot be used with the __local and __global address
+ // space qualifiers.
+ if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local ||
+ R.getAddressSpace() == LangAS::opencl_global)) {
+ Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+ }
+
// OpenCL 1.2 spec, p6.9 r:
// The event type cannot be used to declare a program scope variable.
// The event type cannot be used with the __local, __constant and __global