2012-06-20 07:09:52 +08:00
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
2015-09-30 22:08:20 +08:00
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}}
2012-06-20 07:09:52 +08:00
2017-10-13 11:37:48 +08:00
static float g_implicit_static_var = 0 ; // expected-error {{program scope variable must reside in constant address space}}
static constant float g_constant_static_var = 0 ;
static global float g_global_static_var = 0 ; // expected-error {{program scope variable must reside in constant address space}}
static local float g_local_static_var = 0 ; // expected-error {{program scope variable must reside in constant address space}}
static private float g_private_static_var = 0 ; // expected-error {{program scope variable must reside in constant address space}}
[OpenCL] Restrict various keywords in OpenCL C++ mode
Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.
- dynamic_cast
- typeid
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- exceptions (try/catch/throw)
- access qualifiers read_only, write_only, read_write
Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++. Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++. libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global<T>` that are
implemented using the `__`-prefixed qualifiers.
Differential Revision: https://reviews.llvm.org/D46022
llvm-svn: 331874
2018-05-09 21:16:17 +08:00
static generic float g_generic_static_var = 0 ; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
2017-10-13 11:37:48 +08:00
extern float g_implicit_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern constant float g_constant_extern_var ;
extern global float g_global_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern local float g_local_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern private float g_private_extern_var ; // expected-error {{extern variable must reside in constant address space}}
[OpenCL] Restrict various keywords in OpenCL C++ mode
Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.
- dynamic_cast
- typeid
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- exceptions (try/catch/throw)
- access qualifiers read_only, write_only, read_write
Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++. Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++. libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global<T>` that are
implemented using the `__`-prefixed qualifiers.
Differential Revision: https://reviews.llvm.org/D46022
llvm-svn: 331874
2018-05-09 21:16:17 +08:00
extern generic float g_generic_extern_var ; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
2017-10-13 11:37:48 +08:00
2017-05-15 22:47:47 +08:00
void kernel foo ( int x ) {
2015-09-30 22:08:20 +08:00
// 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 ;
2017-06-20 22:50:45 +08:00
if ( true ) {
local int L1 ; // expected-error {{variables in the local address space can only be declared in the outermost scope of a kernel function}}
constant int L1 = 42 ; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
}
[OpenCL] Restrict various keywords in OpenCL C++ mode
Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.
- dynamic_cast
- typeid
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- exceptions (try/catch/throw)
- access qualifiers read_only, write_only, read_write
Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++. Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++. libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global<T>` that are
implemented using the `__`-prefixed qualifiers.
Differential Revision: https://reviews.llvm.org/D46022
llvm-svn: 331874
2018-05-09 21:16:17 +08:00
auto int L3 = 7 ; // expected-error{{OpenCL C version 1.2 does not support the 'auto' storage class specifier}}
2017-05-19 02:51:09 +08:00
global int L4 ; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__ ( ( address_space ( 100 ) ) ) int L5 ; // expected-error{{automatic variable qualified with an invalid address space}}
constant int L6 = x ; // expected-error {{initializer element is not a compile-time constant}}
global int *constant L7 = &G4 ;
private int *constant L8 = &x ; // expected-error {{initializer element is not a compile-time constant}}
constant int *constant L9 = &L1 ;
local int *constant L10 = &L2 ; // expected-error {{initializer element is not a compile-time constant}}
2012-06-20 07:09:52 +08:00
}
static void kernel bar ( ) { // expected-error{{kernel functions cannot be declared static}}
}
2015-09-30 22:08:20 +08:00
void f ( ) {
2017-05-19 02:51:09 +08:00
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}}
global int L3 ; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__ ( ( address_space ( 100 ) ) ) int L4 ; // expected-error{{automatic variable qualified with an invalid address space}}
2015-09-30 22:08:20 +08:00
{
2017-05-19 02:51:09 +08:00
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}}
global int L3 ; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__ ( ( address_space ( 100 ) ) ) int L4 ; // expected-error{{automatic variable qualified with an invalid address space}}
2015-09-30 22:08:20 +08:00
}
2017-05-19 02:51:09 +08:00
2017-10-13 11:37:48 +08:00
static float l_implicit_static_var = 0 ; // expected-error {{variables in function scope cannot be declared static}}
static constant float l_constant_static_var = 0 ; // expected-error {{variables in function scope cannot be declared static}}
static global float l_global_static_var = 0 ; // expected-error {{variables in function scope cannot be declared static}}
static local float l_local_static_var = 0 ; // expected-error {{variables in function scope cannot be declared static}}
static private float l_private_static_var = 0 ; // expected-error {{variables in function scope cannot be declared static}}
[OpenCL] Restrict various keywords in OpenCL C++ mode
Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.
- dynamic_cast
- typeid
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- exceptions (try/catch/throw)
- access qualifiers read_only, write_only, read_write
Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++. Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++. libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global<T>` that are
implemented using the `__`-prefixed qualifiers.
Differential Revision: https://reviews.llvm.org/D46022
llvm-svn: 331874
2018-05-09 21:16:17 +08:00
static generic float l_generic_static_var = 0 ; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{variables in function scope cannot be declared static}}
2017-05-19 02:51:09 +08:00
2017-10-13 11:37:48 +08:00
extern float l_implicit_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern constant float l_constant_extern_var ;
extern global float l_global_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern local float l_local_extern_var ; // expected-error {{extern variable must reside in constant address space}}
extern private float l_private_extern_var ; // expected-error {{extern variable must reside in constant address space}}
[OpenCL] Restrict various keywords in OpenCL C++ mode
Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.
- dynamic_cast
- typeid
- register (already restricted in OpenCL C, update the diagnostic)
- thread_local
- exceptions (try/catch/throw)
- access qualifiers read_only, write_only, read_write
Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++. Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++. libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global<T>` that are
implemented using the `__`-prefixed qualifiers.
Differential Revision: https://reviews.llvm.org/D46022
llvm-svn: 331874
2018-05-09 21:16:17 +08:00
extern generic float l_generic_extern_var ; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
2015-09-30 22:08:20 +08:00
}