[PATCH] D53871: [OpenCL] Allow clk_event_t comparisons

Sven van Haastregt via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 1 05:45:23 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC345825: Allow clk_event_t comparisons (authored by svenvh, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53871?vs=171711&id=172110#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53871

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/clk_event_t.cl
  test/SemaOpenCL/invalid-clk-events-cl2.0.cl


Index: test/SemaOpenCL/clk_event_t.cl
===================================================================
--- test/SemaOpenCL/clk_event_t.cl
+++ test/SemaOpenCL/clk_event_t.cl
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+// Taken from opencl-c.h
+#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+
+global clk_event_t ce; // expected-error {{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
+
+int clk_event_tests() {
+  event_t e;
+  clk_event_t ce1;
+  clk_event_t ce2;
+
+  if (e == ce1) { // expected-error {{invalid operands to binary expression ('event_t' and 'clk_event_t')}}
+    return 9;
+  }
+
+  if (ce1 != ce2) {
+    return 1;
+  }
+  else if (ce1 == CLK_NULL_EVENT || ce2 != CLK_NULL_EVENT) {
+    return 0;
+  }
+
+  return 2;
+}
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10497,6 +10497,10 @@
   }
 
   if (getLangOpts().OpenCLVersion >= 200) {
+    if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
+      return computeResultTy();
+    }
+
     if (LHSType->isQueueT() && RHSType->isQueueT()) {
       return computeResultTy();
     }
Index: test/SemaOpenCL/invalid-clk-events-cl2.0.cl
===================================================================
--- test/SemaOpenCL/invalid-clk-events-cl2.0.cl
+++ test/SemaOpenCL/invalid-clk-events-cl2.0.cl
@@ -1,3 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
-
-global clk_event_t ce; // expected-error {{the '__global clk_event_t' type cannot be used to declare a program scope variable}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53871.172110.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181101/e5239a92/attachment-0001.bin>


More information about the cfe-commits mailing list