Topotuna created this revision. Herald added subscribers: ldrumm, Anastasia, yaxunl. Topotuna requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
NULL macro maps to ((void*)0) for OpenCL versions earlier than 2.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. Fixes llvm.org/PR48102 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D105988 Files: clang/lib/Headers/opencl-c-base.h clang/test/SemaOpenCL/null_literal.cl Index: clang/test/SemaOpenCL/null_literal.cl =================================================================== --- clang/test/SemaOpenCL/null_literal.cl +++ clang/test/SemaOpenCL/null_literal.cl @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s #define NULL ((void*)0) Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -164,7 +164,7 @@ typedef double double16 __attribute__((ext_vector_type(16))); #endif -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__) #define NULL ((void*)0) #endif
Index: clang/test/SemaOpenCL/null_literal.cl =================================================================== --- clang/test/SemaOpenCL/null_literal.cl +++ clang/test/SemaOpenCL/null_literal.cl @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s +// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s #define NULL ((void*)0) Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -164,7 +164,7 @@ typedef double double16 __attribute__((ext_vector_type(16))); #endif -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__) #define NULL ((void*)0) #endif
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits