1 // RUN
: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
2 // RUN
: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std
=CL2.0 -cl-ext
=-cl_khr_int64_base_atomics
3 // RUN
: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std
=CL2.0
4 // RUN
: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std
=CLC
++
5 // RUN
: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std
=CL2.0 -cl-ext
=-cl_khr_int64_base_atomics
7 #if defined
(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__
>= CL_VERSION_2_0
11 void atomic_types_test
(void) {
12 // OpenCL v2.0 s6.13
.11.6 defines supported atomic types.
19 #if
!defined
(LANG_VER_OK)
20 // expected-error
@-
5 {{use of undeclared identifier
'atomic_int
'}}
21 // expected-error
@-
5 {{use of undeclared identifier
'atomic_uint
'}}
22 // expected-error
@-
5 {{use of undeclared identifier
'atomic_float
'}}
23 // expected-error
@-
5 {{use of undeclared identifier
'atomic_flag
'}}
34 // Optional type identifiers are not added in earlier version or if at least
35 // one of the extensions is not supported. Here we check with
36 // `cl_khr_int64_base_atomics
` only.
37 #if
!defined
(LANG_VER_OK) ||
!defined
(cl_khr_int64_base_atomics)
38 // expected-error
@-
11 {{use of undeclared identifier
'atomic_long
'}}
39 // expected-error
@-
11 {{use of undeclared identifier
'atomic_ulong
'}}
40 // expected-error
@-
11 {{use of undeclared identifier
'atomic_double
'}}
41 #if defined
(LANG_VER_OK)
42 // expected-error
@-
15 {{expected
';' after expression}}
43 // expected-error
@-
16 {{use of undeclared identifier
'l
'}}
44 // expected-error
@-
16 {{expected
';' after expression}}
45 // expected-error
@-
17 {{use of undeclared identifier
'ul
'}}
47 #if
!defined
(LANG_VER_OK) || defined
(__SPIR64__)
48 // expected-error
@-
18 {{use of undeclared identifier
'atomic_size_t
'}}
49 // expected-error
@-
16 {{use of undeclared identifier
'atomic_ptrdiff_t
'}}
50 #if
!defined
(LANG_VER_OK)
51 // expected-error
@-
20 {{use of undeclared identifier
'atomic_intptr_t
'}}
52 // expected-error
@-
20 {{use of undeclared identifier
'atomic_uintptr_t
'}}
54 // expected-error
@-
24 {{expected
';' after expression}}
55 // expected-error
@-
25 {{use of undeclared identifier
's
'}}
56 // expected-error
@-
25 {{unknown type name
'atomic_intptr_t
'; did you mean 'atomic_int'?}}
57 // expected-note
@* {{'atomic_int
' declared here
}}
58 // expected-error
@-
26 {{unknown type name
'atomic_uintptr_t
'; did you mean 'atomic_uint'?}}
59 // expected-note
@* {{'atomic_uint
' declared here
}}
64 // OpenCL v2.0 s6.13
.11.8, _Atomic type specifier and _Atomic type qualifier
65 // are not supported by OpenCL.
67 #ifdef __OPENCL_C_VERSION__
68 // expected-error
@-
2 {{use of undeclared identifier
'_Atomic
'}}
70 // expected-error
@-
4 {{unknown type name
'_Atomic
'}}
74 #if defined
(LANG_VER_OK)
75 int atomic_uint
; //expected-error{{redefinition of 'atomic_uint' as different kind of symbol}}
76 void foo
(atomic_int * ptr
) {}
77 void atomic_ops_test
() {
80 // OpenCL v2.0 s6.13
.11.8, arithemtic operations are not permitted on atomic types.
81 i
++; // expected-error {{invalid argument type '__private atomic_int' (aka '__private _Atomic(int)') to unary expression}}
82 i
= 1; // expected-error {{atomic variable can be assigned to a variable only in global address space}}
83 i
+= 1; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and 'int')}}
84 i
= i
+ i
; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and '__private atomic_int')}}
87 __constant int atomic_uint
= 1;