|
1 |
| -// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -Wno-return-type -sycl-std=2017 -Wno-sycl-2017-compat -fcxx-exceptions -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s |
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -verify %s |
2 | 2 |
|
3 |
| -#include "sycl.hpp" |
| 3 | +// Test that checks 'no_global_work_offset' attribute support on function. |
4 | 4 |
|
5 |
| -using namespace cl::sycl; |
6 |
| -queue q; |
| 5 | +// Tests for incorrect argument values for Intel FPGA 'no_global_work_offset' function attribute. |
| 6 | +[[intel::no_global_work_offset(1)]] int a; // expected-error{{'no_global_work_offset' attribute only applies to functions}} |
7 | 7 |
|
8 |
| -//expected-warning@+1 {{unknown attribute 'no_global_work_offset' ignored}} |
9 |
| -[[intelfpga::no_global_work_offset]] void RemovedSpell(); |
| 8 | +[[intel::no_global_work_offset("foo")]] void test() {} // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} |
10 | 9 |
|
11 |
| -struct FuncObj { |
12 |
| - [[intel::no_global_work_offset]] void operator()() const {} |
13 |
| -}; |
| 10 | +[[intel::no_global_work_offset(0, 1)]] void test1() {} // expected-error{{'no_global_work_offset' attribute takes no more than 1 argument}} |
14 | 11 |
|
15 |
| -int main() { |
16 |
| - q.submit([&](handler &h) { |
17 |
| - // CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} |
18 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
19 |
| - // CHECK-NEXT: value: Int 1 |
20 |
| - // CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} |
21 |
| - h.single_task<class test_kernel1>(FuncObj()); |
| 12 | +[[intelfpga::no_global_work_offset]] void RemovedSpell(); // expected-warning {{unknown attribute 'no_global_work_offset' ignored}} |
22 | 13 |
|
23 |
| - // CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} |
24 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
25 |
| - // CHECK-NEXT: value: Int 0 |
26 |
| - // CHECK-NEXT: IntegerLiteral{{.*}}0{{$}} |
27 |
| - h.single_task<class test_kernel2>( |
28 |
| - []() [[intel::no_global_work_offset(0)]]{}); |
| 14 | +// Test that checks wrong function template instantiation and ensures that the type |
| 15 | +// is checked properly when instantiating from the template definition. |
| 16 | +template <typename Ty> |
| 17 | +// expected-error@+1{{integral constant expression must have integral or unscoped enumeration type, not 'S'}} |
| 18 | +[[intel::no_global_work_offset(Ty{})]] void func() {} |
29 | 19 |
|
30 |
| - // CHECK: SYCLIntelNoGlobalWorkOffsetAttr{{.*}} |
31 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
32 |
| - // CHECK-NEXT: value: Int 42 |
33 |
| - // CHECK-NEXT: IntegerLiteral{{.*}}42{{$}} |
34 |
| - h.single_task<class test_kernel3>( |
35 |
| - []() [[intel::no_global_work_offset(42)]]{}); |
| 20 | +struct S {}; |
| 21 | +void var() { |
| 22 | + // expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}} |
| 23 | + func<S>(); |
| 24 | +} |
| 25 | + |
| 26 | +// Test that checks expression is not a constant expression. |
| 27 | +// expected-note@+1{{declared here}} |
| 28 | +int foo(); |
| 29 | +// expected-error@+2{{expression is not an integral constant expression}} |
| 30 | +// expected-note@+1{{non-constexpr function 'foo' cannot be used in a constant expression}} |
| 31 | +[[intel::no_global_work_offset(foo() + 12)]] void func1(); |
| 32 | + |
| 33 | +// Test that checks expression is a constant expression. |
| 34 | +constexpr int bar() { return 0; } |
| 35 | +[[intel::no_global_work_offset(bar() + 12)]] void func2(); // OK |
| 36 | + |
| 37 | +// No diagnostic is thrown since arguments match. Silently ignore duplicate attribute. |
| 38 | +[[intel::no_global_work_offset]] void func3(); |
| 39 | +[[intel::no_global_work_offset(1)]] void func3() {} // OK |
36 | 40 |
|
37 |
| - // CHECK: SYCLIntelNoGlobalWorkOffsetAttr{{.*}} |
38 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
39 |
| - // CHECK-NEXT: value: Int -1 |
40 |
| - // CHECK-NEXT: UnaryOperator{{.*}} 'int' prefix '-' |
41 |
| - // CHECK-NEXT-NEXT: IntegerLiteral{{.*}}1{{$}} |
42 |
| - h.single_task<class test_kernel4>( |
43 |
| - []() [[intel::no_global_work_offset(-1)]]{}); |
| 41 | +[[intel::no_global_work_offset(0)]] void func4(); // expected-note {{previous attribute is here}} |
| 42 | +[[intel::no_global_work_offset]] void func4(); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} |
44 | 43 |
|
45 |
| - // Ignore duplicate attribute. |
46 |
| - h.single_task<class test_kernel5>( |
47 |
| - // CHECK: SYCLIntelNoGlobalWorkOffsetAttr {{.*}} |
48 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
49 |
| - // CHECK-NEXT: value: Int 1 |
50 |
| - // CHECK-NEXT: IntegerLiteral{{.*}}1{{$}} |
51 |
| - []() [[intel::no_global_work_offset, |
52 |
| - intel::no_global_work_offset]]{}); // OK |
| 44 | +// No diagnostic is emitted because the arguments match. |
| 45 | +[[intel::no_global_work_offset(1)]] void func5(); |
| 46 | +[[intel::no_global_work_offset(1)]] void func5() {} // OK |
53 | 47 |
|
54 |
| - // expected-error@+2{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} |
55 |
| - h.single_task<class test_kernel6>( |
56 |
| - []() [[intel::no_global_work_offset("foo")]]{}); |
| 48 | +// Diagnostic is emitted because the arguments mismatch. |
| 49 | +[[intel::no_global_work_offset(0)]] void func6(); // expected-note {{previous attribute is here}} |
| 50 | +[[intel::no_global_work_offset(1)]] void func6(); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} |
57 | 51 |
|
58 |
| - h.single_task<class test_kernel7>([]() { |
59 |
| - // expected-error@+1{{'no_global_work_offset' attribute only applies to functions}} |
60 |
| - [[intel::no_global_work_offset(1)]] int a; |
61 |
| - }); |
| 52 | +// Test that checks template parameter support on function. |
| 53 | +template <int N> |
| 54 | +[[intel::no_global_work_offset(0)]] void func7(); // expected-note {{previous attribute is here}} |
| 55 | +template <int N> |
| 56 | +[[intel::no_global_work_offset(N)]] void func7() {} // expected-warning {{attribute 'no_global_work_offset' is already applied with different arguments}} |
62 | 57 |
|
63 |
| - h.single_task<class test_kernel8>( |
64 |
| - []() [[intel::no_global_work_offset(0), // expected-note {{previous attribute is here}} |
65 |
| - intel::no_global_work_offset(1)]]{}); // expected-warning{{attribute 'no_global_work_offset' is already applied with different arguments}} |
66 |
| - }); |
| 58 | +int check() { |
| 59 | + func7<1>(); // expected-note {{in instantiation of function template specialization 'func7<1>' requested here}} |
67 | 60 | return 0;
|
68 | 61 | }
|
0 commit comments