Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaOpenCL / null_literal.cl
blobb641c6bd7c6dd54e71ffec96a68600685d42f056
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
5 // RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header -verify %s
7 void foo(){
9 global int* ptr1 = NULL;
11 #if defined(__OPENCL_CPP_VERSION__)
12 // expected-error@+2{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__global void *'}}
13 #endif
14 global int* ptr2 = (global void*)0;
16 constant int* ptr3 = NULL;
18 #if defined(__OPENCL_CPP_VERSION__)
19 // expected-error@+4{{cannot initialize a variable of type '__constant int *__private' with an rvalue of type '__global void *'}}
20 #else
21 // expected-error@+2{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
22 #endif
23 constant int* ptr4 = (global void*)0;
25 #if __OPENCL_C_VERSION__ == CL_VERSION_2_0
26 // Accept explicitly pointer to generic address space in OpenCL v2.0.
27 global int* ptr5 = (generic void*)0;
28 #endif
30 #if defined(__OPENCL_CPP_VERSION__)
31 // expected-error@+4{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__local void *'}}
32 #else
33 // expected-error@+2{{initializing '__global int *__private' with an expression of type '__local void *' changes address space of pointer}}
34 #endif
35 global int* ptr6 = (local void*)0;
37 bool cmp = ptr1 == NULL;
39 #if defined(__OPENCL_CPP_VERSION__)
40 // expected-error@+4{{comparison of distinct pointer types ('__global int *' and '__local void *')}}
41 #else
42 // expected-error@+2{{comparison between ('__global int *' and '__local void *') which are pointers to non-overlapping address spaces}}
43 #endif
44 cmp = ptr1 == (local void*)0;
46 cmp = ptr3 == NULL;