svenvh created this revision.
svenvh added reviewers: Anastasia, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Defining CLK_NULL_EVENT with a `(void*)` cast has the (unintended?)
side-effect that the address space will be fixed (as generic in OpenCL
2.0 mode). The consequence is that any target specific address space
for the clk_event_t type will not be applied.
It is not clear why the void pointer cast was needed in the first
place, and it seems we can do without it.
Repository:
rC Clang
https://reviews.llvm.org/D63876
Files:
lib/Headers/opencl-c-base.h
test/SemaOpenCL/clk_event_t.cl
Index: test/SemaOpenCL/clk_event_t.cl
===================================================================
--- test/SemaOpenCL/clk_event_t.cl
+++ test/SemaOpenCL/clk_event_t.cl
@@ -2,7 +2,7 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
// Taken from opencl-c.h
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__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}}
@@ -10,6 +10,7 @@
event_t e;
clk_event_t ce1;
clk_event_t ce2;
+ clk_event_t ce3 = CLK_NULL_EVENT;
if (e == ce1) { // expected-error {{invalid operands to binary expression
('event_t' and 'clk_event_t')}}
return 9;
Index: lib/Headers/opencl-c-base.h
===================================================================
--- lib/Headers/opencl-c-base.h
+++ lib/Headers/opencl-c-base.h
@@ -413,7 +413,7 @@
#define CLK_OUT_OF_RESOURCES -5
#define CLK_NULL_QUEUE 0
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
// execution model related definitions
#define CLK_ENQUEUE_FLAGS_NO_WAIT 0x0
Index: test/SemaOpenCL/clk_event_t.cl
===================================================================
--- test/SemaOpenCL/clk_event_t.cl
+++ test/SemaOpenCL/clk_event_t.cl
@@ -2,7 +2,7 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
// Taken from opencl-c.h
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__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}}
@@ -10,6 +10,7 @@
event_t e;
clk_event_t ce1;
clk_event_t ce2;
+ clk_event_t ce3 = CLK_NULL_EVENT;
if (e == ce1) { // expected-error {{invalid operands to binary expression ('event_t' and 'clk_event_t')}}
return 9;
Index: lib/Headers/opencl-c-base.h
===================================================================
--- lib/Headers/opencl-c-base.h
+++ lib/Headers/opencl-c-base.h
@@ -413,7 +413,7 @@
#define CLK_OUT_OF_RESOURCES -5
#define CLK_NULL_QUEUE 0
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
// execution model related definitions
#define CLK_ENQUEUE_FLAGS_NO_WAIT 0x0
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits