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
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>();
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to