45 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s2 3// Only function templates4[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'clang::sycl_kernel' attribute only applies to function templates}}5__attribute__((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}6 7__attribute__((sycl_kernel)) void foo(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}8[[clang::sycl_kernel]] void foo1(); // expected-warning {{'clang::sycl_kernel' attribute only applies to function templates}}9 10// Attribute takes no arguments11template <typename T, typename A>12__attribute__((sycl_kernel(1))) void foo(T P); // expected-error {{'sycl_kernel' attribute takes no arguments}}13template <typename T, typename A, int I>14[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'clang::sycl_kernel' attribute takes no arguments}}15 16// At least two template parameters17template <typename T>18__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}19template <typename T>20[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}21 22// First two template parameters cannot be non-type template parameters23template <typename T, int A>24__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}25template <int A, typename T>26[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}27 28// Must return void29template <typename T, typename A>30__attribute__((sycl_kernel)) int foo(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}31template <typename T, typename A>32[[clang::sycl_kernel]] int foo1(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}33 34// Must take at least one argument35template <typename T, typename A>36__attribute__((sycl_kernel)) void foo(); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}37template <typename T, typename A>38[[clang::sycl_kernel]] void foo1(T t, A a); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}39 40// No diagnostics41template <typename T, typename A>42__attribute__((sycl_kernel)) void foo(T P);43template <typename T, typename A, int I>44[[clang::sycl_kernel]] void foo1(T P);45