[PATCH] D31594: [OpenCL] Enables passing sampler initializer to function argument

Egor Churaev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 3 03:18:40 PDT 2017


echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D31594

Files:
  lib/Sema/SemaInit.cpp
  test/SemaOpenCL/sampler_t.cl


Index: test/SemaOpenCL/sampler_t.cl
===================================================================
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -65,7 +65,7 @@
   foo(const_smp5);
   foo(const_smp6);
   foo(argsmp);
-  foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+  foo(CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR);
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
   foo(sa[0]);
   foo(bad());
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7174,7 +7174,7 @@
       QualType SourceType = Init->getType();
       // Case 1
       if (Entity.isParameterKind()) {
-        if (!SourceType->isSamplerT()) {
+        if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
           S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
             << SourceType;
           break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31594.93838.patch
Type: text/x-patch
Size: 1050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170403/47a7bbd9/attachment.bin>


More information about the cfe-commits mailing list