summaryrefslogtreecommitdiff
path: root/test/SemaOpenCL
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
commit45b533945f0851ec234ca846e1af5ee1e4df0b6e (patch)
tree0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /test/SemaOpenCL
parent7e86edd64bfae4e324224452e4ea879b3371a4bd (diff)
Notes
Diffstat (limited to 'test/SemaOpenCL')
-rw-r--r--test/SemaOpenCL/cond.cl6
-rw-r--r--test/SemaOpenCL/null_literal.cl29
-rw-r--r--test/SemaOpenCL/storageclass-cl20.cl15
-rw-r--r--test/SemaOpenCL/storageclass.cl27
4 files changed, 68 insertions, 9 deletions
diff --git a/test/SemaOpenCL/cond.cl b/test/SemaOpenCL/cond.cl
index a1e32df16d56..8cc4f1e8e910 100644
--- a/test/SemaOpenCL/cond.cl
+++ b/test/SemaOpenCL/cond.cl
@@ -84,12 +84,12 @@ uchar2 ntest03(int2 C, uchar X, uchar Y)
float2 ntest04(int2 C, int2 X, float2 Y)
{
- return C ? X : Y; // expected-error {{can't convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values))}}
+ return C ? X : Y; // expected-error {{implicit conversions between vector types ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values)) are not permitted}}
}
float2 ntest05(int2 C, int2 X, float Y)
{
- return C ? X : Y; // expected-error {{can't convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float')}}
+ return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float')}}
}
char2 ntest06(int2 C, char2 X, char2 Y)
@@ -115,7 +115,7 @@ int2 ntest09(int2 C, global int *X, global int *Y)
char3 ntest10(char C, char3 X, char2 Y)
{
- return C ? X : Y; // expected-error {{can't convert between vector values of different size ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values))}}
+ return C ? X : Y; // expected-error {{implicit conversions between vector types ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values)) are not permitted}}
}
char3 ntest11(char2 C, char3 X, char Y)
diff --git a/test/SemaOpenCL/null_literal.cl b/test/SemaOpenCL/null_literal.cl
new file mode 100644
index 000000000000..2fb287270f46
--- /dev/null
+++ b/test/SemaOpenCL/null_literal.cl
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
+
+#define NULL ((void*)0)
+
+void foo(){
+
+global int* ptr1 = NULL;
+
+global int* ptr2 = (global void*)0;
+
+constant int* ptr3 = NULL;
+
+constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}}
+
+#ifdef CL20
+// Accept explicitly pointer to generic address space in OpenCL v2.0.
+global int* ptr5 = (generic void*)0;
+#endif
+
+global int* ptr6 = (local void*)0; // expected-error{{initializing '__global int *' with an expression of type '__local void *' changes address space of pointer}}
+
+bool cmp = ptr1 == NULL;
+
+cmp = ptr1 == (local void*)0; // expected-error{{comparison between ('__global int *' and '__local void *') which are pointers to non-overlapping address spaces}}
+
+cmp = ptr3 == NULL;
+
+}
diff --git a/test/SemaOpenCL/storageclass-cl20.cl b/test/SemaOpenCL/storageclass-cl20.cl
new file mode 100644
index 000000000000..c8e7faa208f1
--- /dev/null
+++ b/test/SemaOpenCL/storageclass-cl20.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
+
+static constant int G1 = 0;
+int G2 = 0;
+global int G3 = 0;
+local int G4 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+
+void kernel foo() {
+ static int S1 = 5;
+ static global int S2 = 5;
+ static private int S3 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+
+ constant int L1 = 0;
+ local int L2;
+}
diff --git a/test/SemaOpenCL/storageclass.cl b/test/SemaOpenCL/storageclass.cl
index d2678f2010d9..c7d8ab984687 100644
--- a/test/SemaOpenCL/storageclass.cl
+++ b/test/SemaOpenCL/storageclass.cl
@@ -1,14 +1,29 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-static constant int A = 0;
+static constant int G1 = 0;
+constant int G2 = 0;
+int G3 = 0; // expected-error{{program scope variable must reside in constant address space}}
+global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
-int X = 0; // expected-error{{global variables must have a constant address space qualifier}}
-
-// static is not allowed at local scope.
void kernel foo() {
- static int X = 5; // expected-error{{variables in function scope cannot be declared static}}
- auto int Y = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+ // static is not allowed at local scope before CL2.0
+ static int S1 = 5; // expected-error{{variables in function scope cannot be declared static}}
+ static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
+
+ constant int L1 = 0;
+ local int L2;
+
+ auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
}
static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
}
+
+void f() {
+ constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
+ local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
+ {
+ constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
+ local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
+ }
+}