brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 2cd2c6c Raw
83 lines · plain
1// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only2// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics3// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.04// 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_atomics6 7#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_08#define LANG_VER_OK9#endif10 11void atomic_types_test(void) {12// OpenCL v2.0 s6.13.11.6 defines supported atomic types.13 14// Non-optional types15  atomic_int i;16  atomic_uint ui;17  atomic_float f;18  atomic_flag fl;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'}}24#endif25 26// Optional types27  atomic_long l;28  atomic_ulong ul;29  atomic_double d;30  atomic_size_t s;31  atomic_intptr_t ip;32  atomic_uintptr_t uip;33  atomic_ptrdiff_t pd;34// Optional type identifiers are not added in earlier version or if at least35// one of the extensions is not supported. Here we check with36// `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#endif43#if !defined(LANG_VER_OK) || defined(__SPIR64__)44// expected-error@-14 {{use of undeclared identifier 'atomic_size_t'}}45// expected-error@-12 {{use of undeclared identifier 'atomic_ptrdiff_t'}}46#if !defined(LANG_VER_OK)47// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}48// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}49#else50// expected-error@-19 {{unknown type name 'atomic_intptr_t'; did you mean 'atomic_int'?}}51// expected-note@* {{'atomic_int' declared here}}52// expected-error@-20 {{unknown type name 'atomic_uintptr_t'; did you mean 'atomic_uint'?}}53// expected-note@* {{'atomic_uint' declared here}}54#endif55#endif56#endif57 58// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier59// are not supported by OpenCL.60  _Atomic int i;61#ifdef __OPENCL_C_VERSION__62// expected-error@-2 {{use of undeclared identifier '_Atomic'}}63#else64 // expected-error@-4 {{unknown type name '_Atomic'}}65#endif66}67 68#if defined(LANG_VER_OK)69int atomic_uint; //expected-error{{redefinition of 'atomic_uint' as different kind of symbol}}70void foo(atomic_int * ptr) {}71void atomic_ops_test() {72  atomic_int i;73  foo(&i);74// OpenCL v2.0 s6.13.11.8, arithemtic operations are not permitted on atomic types.75  i++; // expected-error {{invalid argument type '__private atomic_int' (aka '__private _Atomic(int)') to unary expression}}76  i = 1; // expected-error {{atomic variable can be assigned to a variable only in global address space}}77  i += 1; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and 'int')}}78  i = i + i; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and '__private atomic_int')}}79}80#else81__constant int atomic_uint = 1;82#endif83