Tanya Lattner | 4fdce3f | 2012-06-19 23:09:52 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 |
| 2 | |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 3 | static constant int G1 = 0; |
| 4 | constant int G2 = 0; |
| 5 | int G3 = 0; // expected-error{{program scope variable must reside in constant address space}} |
| 6 | global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}} |
Tanya Lattner | 4fdce3f | 2012-06-19 23:09:52 +0000 | [diff] [blame] | 7 | |
Yaxun Liu | b7318e0 | 2017-10-13 03:37:48 +0000 | [diff] [blame] | 8 | static float g_implicit_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} |
| 9 | static constant float g_constant_static_var = 0; |
| 10 | static global float g_global_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} |
| 11 | static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} |
| 12 | static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} |
| 13 | static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}} |
| 14 | |
| 15 | extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 16 | extern constant float g_constant_extern_var; |
| 17 | extern global float g_global_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 18 | extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 19 | extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 20 | extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} |
| 21 | |
Yaxun Liu | 4f33b3d | 2017-05-15 14:47:47 +0000 | [diff] [blame] | 22 | void kernel foo(int x) { |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 23 | // static is not allowed at local scope before CL2.0 |
| 24 | static int S1 = 5; // expected-error{{variables in function scope cannot be declared static}} |
| 25 | static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}} |
| 26 | |
| 27 | constant int L1 = 0; |
| 28 | local int L2; |
| 29 | |
Anastasia Stulova | e437b6a | 2017-06-20 14:50:45 +0000 | [diff] [blame] | 30 | if (true) { |
| 31 | local int L1; // expected-error {{variables in the local address space can only be declared in the outermost scope of a kernel function}} |
| 32 | constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}} |
| 33 | } |
| 34 | |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 35 | auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}} |
| 36 | global int L4; // expected-error{{function scope variable cannot be declared in global address space}} |
| 37 | __attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}} |
Yaxun Liu | 4f33b3d | 2017-05-15 14:47:47 +0000 | [diff] [blame] | 38 | |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 39 | constant int L6 = x; // expected-error {{initializer element is not a compile-time constant}} |
| 40 | global int *constant L7 = &G4; |
| 41 | private int *constant L8 = &x; // expected-error {{initializer element is not a compile-time constant}} |
| 42 | constant int *constant L9 = &L1; |
| 43 | local int *constant L10 = &L2; // expected-error {{initializer element is not a compile-time constant}} |
Tanya Lattner | 4fdce3f | 2012-06-19 23:09:52 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static void kernel bar() { // expected-error{{kernel functions cannot be declared static}} |
| 47 | } |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 48 | |
| 49 | void f() { |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 50 | constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}} |
| 51 | local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}} |
| 52 | global int L3; // expected-error{{function scope variable cannot be declared in global address space}} |
| 53 | __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}} |
| 54 | |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 55 | { |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 56 | constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}} |
| 57 | local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}} |
| 58 | global int L3; // expected-error{{function scope variable cannot be declared in global address space}} |
| 59 | __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}} |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 60 | } |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 61 | |
Yaxun Liu | b7318e0 | 2017-10-13 03:37:48 +0000 | [diff] [blame] | 62 | static float l_implicit_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} |
| 63 | static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} |
| 64 | static global float l_global_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} |
| 65 | static local float l_local_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} |
| 66 | static private float l_private_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} |
| 67 | static generic float l_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{variables in function scope cannot be declared static}} |
Yaxun Liu | 6d96f163 | 2017-05-18 18:51:09 +0000 | [diff] [blame] | 68 | |
Yaxun Liu | b7318e0 | 2017-10-13 03:37:48 +0000 | [diff] [blame] | 69 | extern float l_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 70 | extern constant float l_constant_extern_var; |
| 71 | extern global float l_global_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 72 | extern local float l_local_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 73 | extern private float l_private_extern_var; // expected-error {{extern variable must reside in constant address space}} |
| 74 | extern generic float l_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} |
Anastasia Stulova | bcea696 | 2015-09-30 14:08:20 +0000 | [diff] [blame] | 75 | } |