[cfe-commits] Explicit type cast of zero to OpenCL event_t type

jingu kang jaykang10 at gmail.com
Thu May 2 15:54:52 PDT 2013


Hi all,

I have a question. Clang allows implicit type cast of zero to OpenCL
event_t type to support OpenCL async_work_group_copy() function. But
explicit type cast generates the error. Could someone explain about this
why clang prevent explicit type cast of zero to OpenCL event_t type? I
think OpenCL spec does not mention about implicit or explicit type cast to
event_t type. I have attached the simple patch to support explicit type
cast on the assumption that it is needed.

Please review this patch.

Thanks,
JinGu Kang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130503/e88be62e/attachment.html>
-------------- next part --------------
Index: lib/Sema/SemaCast.cpp
===================================================================
--- lib/Sema/SemaCast.cpp   (revision 180955)
+++ lib/Sema/SemaCast.cpp   (working copy)
@@ -2096,6 +2096,20 @@
     return;
   }

+  //
+  // OpenCL 1.2 spec, s6.12.10
+  //
+  // The event argument can also be used to associate the
+  // async_work_group_copy with a previous async copy allowing
+  // an event to be shared by multiple async copies; otherwise
+  // event should be zero.
+  //
+  if (Self.getLangOpts().OpenCL && DestType->isEventT() &&
+      SrcExpr.take()->EvaluateKnownConstInt(Self.getASTContext()) == 0) {
+    Kind = CK_ZeroToOCLEvent;
+    return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
     const RecordType *DestRecordTy = DestType->getAs<RecordType>();


More information about the cfe-commits mailing list