llvm/clang/test/SemaOpenCLCXX/template-opencl-types.clcpp

// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only

template<typename T>
T global_variable; // expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}

clk_event_t global_event; // expected-error{{the '__global clk_event_t' type cannot be used to declare a program scope variable}}

template<typename T>
void templ() {
  T loc;
  // expected-error@-1{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
  // expected-error@-2{{declaring variable of type '__private half' is not allowed}}
  // expected-error@-3{{the event_t type can only be used with __private address space qualifier}}
}

void foo() {
  templ<image1d_t>(); // expected-note{{in instantiation of function template specialization 'templ<__read_only image1d_t>' requested here}}
  templ<half>(); // expected-note{{in instantiation of function template specialization 'templ<half>' requested here}}
  templ<__local event_t>(); // expected-note{{in instantiation of function template specialization 'templ<__local event_t>' requested here}}

  image1d_t img; // expected-error{{type '__private __read_only image1d_t' can only be used as a function parameter in OpenCL}}
  half h; // expected-error{{declaring variable of type '__private half' is not allowed}}
  __local event_t e; // expected-error{{the event_t type can only be used with __private address space qualifier}}

  (void) global_variable<clk_event_t>; // expected-note{{in instantiation of variable template specialization 'global_variable' requested here}}
}