Skip to content

Commit e9e59ad

Browse files
committed
[OpenCL] Define CLK_NULL_EVENT without cast
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. Differential Revision: https://reviews.llvm.org/D63876 llvm-svn: 366546
1 parent f3ae501 commit e9e59ad

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Headers/opencl-c-base.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ typedef enum memory_order
413413
#define CLK_OUT_OF_RESOURCES -5
414414

415415
#define CLK_NULL_QUEUE 0
416-
#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
416+
#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
417417

418418
// execution model related definitions
419419
#define CLK_ENQUEUE_FLAGS_NO_WAIT 0x0

clang/test/SemaOpenCL/clk_event_t.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
33

44
// Taken from opencl-c.h
5-
#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
5+
#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
66

77
global clk_event_t ce; // expected-error {{the '__global clk_event_t' type cannot be used to declare a program scope variable}}
88

99
int clk_event_tests() {
1010
event_t e;
1111
clk_event_t ce1;
1212
clk_event_t ce2;
13+
clk_event_t ce3 = CLK_NULL_EVENT;
1314

1415
if (e == ce1) { // expected-error {{invalid operands to binary expression ('event_t' and 'clk_event_t')}}
1516
return 9;

0 commit comments

Comments
 (0)