diff options
| author | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-09-30 13:18:52 +0000 |
|---|---|---|
| committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2015-09-30 13:18:52 +0000 |
| commit | de0e424e8ae9f5463cfd284ca4694a2092f8b40f (patch) | |
| tree | 759173b9532ce488fd8c1046cff22ed3da7aec6b /clang/test/Parser | |
| parent | 08023c696da5f6f380cbbc3d1db160dfd5975e54 (diff) | |
| download | bcm5719-llvm-de0e424e8ae9f5463cfd284ca4694a2092f8b40f.tar.gz bcm5719-llvm-de0e424e8ae9f5463cfd284ca4694a2092f8b40f.zip | |
[OpenCL 2.0] This change adds extra diagnostics to atomic types
Applied restrictions from OpenCL v2.0 s6.13.11.8
that mainly disallow operations on atomic types (except for taking their address - &).
The patch is taken from SPIR2.0 provisional branch, contributed by Guy Benyei!
llvm-svn: 248896
Diffstat (limited to 'clang/test/Parser')
| -rw-r--r-- | clang/test/Parser/opencl-atomics-cl20.cl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Parser/opencl-atomics-cl20.cl b/clang/test/Parser/opencl-atomics-cl20.cl index c62142b2aa6..cb2f59721ac 100644 --- a/clang/test/Parser/opencl-atomics-cl20.cl +++ b/clang/test/Parser/opencl-atomics-cl20.cl @@ -54,3 +54,16 @@ void atomic_types_test() { // expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}} // expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}} #endif + +#ifdef CL20 +void foo(atomic_int * ptr) {} +void atomic_ops_test() { + atomic_int i; + foo(&i); +// OpenCL v2.0 s6.13.11.8, arithemtic operations are not permitted on atomic types. + i++; // expected-error {{invalid argument type 'atomic_int' (aka '_Atomic(int)') to unary expression}} + i = 1; // expected-error {{atomic variable can only be assigned to a compile time constant in the declaration statement in the program scope}} + i += 1; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'int')}} + i = i + i; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}} +} +#endif |

