Skip to content

Commit 5c63bf3

Browse files
author
Anastasia Stulova
committed
[OpenCL] Add NULL to standards prior to v2.0.
NULL was undefined in OpenCL prior to version 2.0. However, the language specification states that "macro names defined by the C99 specification but not currently supported by OpenCL are reserved for future use". Therefore, application developers cannot redefine NULL. The change is supposed to resolve inconsistency between language versions. Currently there is no apparent reason why NULL should be kept undefined. Patch by Topotuna (Justas Janickas)! Differential Revision: https://reviews.llvm.org/D105988
1 parent fb978f0 commit 5c63bf3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ typedef double double8 __attribute__((ext_vector_type(8)));
169169
typedef double double16 __attribute__((ext_vector_type(16)));
170170
#endif
171171

172-
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
173172
#define NULL ((void*)0)
174-
#endif
175173

176174
/**
177175
* Value of maximum non-infinite single-precision floating-point

clang/test/SemaOpenCL/null_literal.cl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_cc1 -verify %s
2-
// RUN: %clang_cc1 -cl-std=CL2.0 -verify %s
3-
4-
#define NULL ((void*)0)
1+
// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
2+
// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
3+
// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
4+
// RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
55

66
void foo(){
77

0 commit comments

Comments
 (0)