File: null_literal.cl

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (48 lines) | stat: -rw-r--r-- 1,989 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
// RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header -verify %s

void foo(){

global int* ptr1 = NULL;

#if defined(__OPENCL_CPP_VERSION__)
// expected-error@+2{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__global void *'}}
#endif
global int* ptr2 = (global void*)0;

constant int* ptr3 = NULL;

#if defined(__OPENCL_CPP_VERSION__)
// expected-error@+4{{cannot initialize a variable of type '__constant int *__private' with an rvalue of type '__global void *'}}
#else
// expected-error@+2{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
#endif
constant int* ptr4 = (global void*)0;

#if __OPENCL_C_VERSION__ == CL_VERSION_2_0
// Accept explicitly pointer to generic address space in OpenCL v2.0.
global int* ptr5 = (generic void*)0;
#endif

#if defined(__OPENCL_CPP_VERSION__)
// expected-error@+4{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__local void *'}}
#else
// expected-error@+2{{initializing '__global int *__private' with an expression of type '__local void *' changes address space of pointer}}
#endif
global int* ptr6 = (local void*)0;

bool cmp = ptr1 == NULL;

#if defined(__OPENCL_CPP_VERSION__)
// expected-error@+4{{comparison of distinct pointer types ('__global int *' and '__local void *')}}
#else
// expected-error@+2{{comparison between  ('__global int *' and '__local void *') which are pointers to non-overlapping address spaces}}
#endif
cmp = ptr1 == (local void*)0;

cmp = ptr3 == NULL;

}