[PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 03:42:03 PDT 2016


Anastasia added inline comments.

================
Comment at: lib/Sema/SemaInit.cpp:6945
@@ +6944,3 @@
+          // get the integer literal.
+          Init = cast<ImplicitCastExpr>(const_cast<Expr*>(
+            Var->getInit()))->getSubExpr();
----------------
Could you please take a look at the new diagnostics you are adding in DiagnosticSemaKinds.td. I don't think they are all covered by your tests.

I understand that you have to insert the cast even though it looks a bit hacky, so we might need to put more comments here to explain why this is needed. But certainly diagnostics code seems to be doing extra work. For the following code:
 
  constant sampler_t glb_smp = 1L;
  void foo(sampler_t);
  void bar(){
    foo(glb_smp);
  }

I get diagnostics reported twice:
  sampler.cl:1:20: error: sampler_t initialization requires 32-bit integer, not 'long'
  constant sampler_t glb_smp = 1L;
  sampler.cl:6:5: error: sampler_t initialization requires 32-bit integer, not 'long'
  foo(glb_smp);

The second diagnostic doesn't seem right at all.

Could you please take a look.


https://reviews.llvm.org/D21567





More information about the cfe-commits mailing list