Skip to content

Commit f0112fc

Browse files
committed
Add new test cases
Signed-off-by: Soumi Manna <[email protected]>
1 parent 953585c commit f0112fc

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

clang/test/SemaSYCL/sycl-device-intel-max-global-work-dim-template.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
// Test that checks wrong function template instantiation and ensures that the type
66
// is checked properly when instantiating from the template definition.
77
template <typename Ty>
8-
// expected-error@+1{{'max_global_work_dim' attribute requires an integer constant}}
8+
// expected-error@+1 2{{'max_global_work_dim' attribute requires an integer constant}}
99
[[intel::max_global_work_dim(Ty{})]] void func() {}
1010

1111
struct S {};
12-
void var() {
12+
void test() {
1313
//expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}}
1414
func<S>();
15+
//expected-note@+1{{in instantiation of function template specialization 'func<float>' requested here}}
16+
func<float>();
17+
// no error expected
18+
func<int>(); // OK
1519
}
1620

1721
// Test that checks expression is not a constant expression.
@@ -48,10 +52,14 @@ int main() {
4852

4953
// Test that checks template parameter support on function.
5054
template <int N>
55+
// expected-error@+1{{'max_global_work_dim' attribute requires a non-negative integral compile time constant expression}}
5156
[[intel::max_global_work_dim(N)]] void func3() {}
5257

5358
int check() {
59+
// no error expected
5460
func3<2>();
61+
//expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}}
62+
func3<-1>();
5563
return 0;
5664
}
5765

clang/test/SemaSYCL/sycl-device-num_simd_work_items-template.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
// Test that checks wrong function template instantiation and ensures that the type
66
// is checked properly when instantiating from the template definition.
77
template <typename Ty>
8-
// expected-error@+1{{'num_simd_work_items' attribute requires an integer constant}}
8+
// expected-error@+2{{'num_simd_work_items' attribute requires a positive integral compile time constant expression}}
9+
// expected-error@+1 2{{'num_simd_work_items' attribute requires an integer constant}}
910
[[intel::num_simd_work_items(Ty{})]] void func() {}
1011

1112
struct S {};
12-
void var() {
13+
void test() {
1314
//expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}}
1415
func<S>();
16+
//expected-note@+1{{in instantiation of function template specialization 'func<float>' requested here}}
17+
func<float>();
18+
//expected-note@+1{{in instantiation of function template specialization 'func<int>' requested here}}
19+
func<int>();
1520
}
1621

1722
// Test that checks expression is not a constant expression.
@@ -36,6 +41,7 @@ int main() {
3641
KernelFunctor<-1>();
3742
// no error expected
3843
KernelFunctor<10>();
44+
return 0;
3945
}
4046

4147
// CHECK: ClassTemplateDecl {{.*}} {{.*}} KernelFunctor
@@ -48,10 +54,14 @@ int main() {
4854

4955
// Test that checks template parameter support on function.
5056
template <int N>
57+
// expected-error@+1{{'num_simd_work_items' attribute requires a positive integral compile time constant expression}}
5158
[[intel::num_simd_work_items(N)]] void func3() {}
5259

5360
int check() {
61+
// no error expected
5462
func3<8>();
63+
//expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}}
64+
func3<-1>();
5565
return 0;
5666
}
5767

clang/test/SemaSYCL/sycl-device-reqd-sub-group-size-template.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
// Test that checks wrong function template instantiation and ensures that the type
66
// is checked properly when instantiating from the template definition.
77
template <typename Ty>
8-
// expected-error@+1{{'reqd_sub_group_size' attribute requires an integer constant}}
8+
// expected-error@+2{{'reqd_sub_group_size' attribute requires a positive integral compile time constant expression}}
9+
// expected-error@+1 2{{'reqd_sub_group_size' attribute requires an integer constant}}
910
[[intel::reqd_sub_group_size(Ty{})]] void func() {}
1011

1112
struct S {};
12-
void var() {
13+
void test() {
1314
//expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}}
1415
func<S>();
16+
//expected-note@+1{{in instantiation of function template specialization 'func<float>' requested here}}
17+
func<float>();
18+
//expected-note@+1{{in instantiation of function template specialization 'func<int>' requested here}}
19+
func<int>();
1520
}
1621

1722
// Test that checks expression is not a constant expression.
@@ -36,6 +41,7 @@ int main() {
3641
KernelFunctor<-1>();
3742
// no error expected
3843
KernelFunctor<10>();
44+
return 0;
3945
}
4046

4147
// CHECK: ClassTemplateDecl {{.*}} {{.*}} KernelFunctor
@@ -48,10 +54,14 @@ int main() {
4854

4955
// Test that checks template parameter support on function.
5056
template <int N>
57+
// expected-error@+1{{'reqd_sub_group_size' attribute requires a positive integral compile time constant expression}}
5158
[[intel::reqd_sub_group_size(N)]] void func3() {}
5259

5360
int check() {
61+
// no error expected
5462
func3<12>();
63+
//expected-note@+1{{in instantiation of function template specialization 'func3<-1>' requested here}}
64+
func3<-1>();
5565
return 0;
5666
}
5767

0 commit comments

Comments
 (0)