Skip to content

Commit 16fcb25

Browse files
committed
use attribute for diag msg
1 parent 450fa2f commit 16fcb25

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5758,8 +5758,7 @@ static void handleClusterDimsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57585758
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57595759
(TTI.getTriple().isAMDGPU() &&
57605760
!TTI.hasFeatureEnabled(TTI.getTargetOpts().FeatureMap, "clusters"))) {
5761-
S.Diag(AL.getLoc(), diag::err_cluster_attr_not_supported)
5762-
<< "__cluster_dims__";
5761+
S.Diag(AL.getLoc(), diag::err_cluster_attr_not_supported) << AL;
57635762
return;
57645763
}
57655764

@@ -5778,8 +5777,7 @@ static void handleNoClusterAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57785777
if ((TTI.getTriple().isNVPTX() && Arch < clang::OffloadArch::SM_90) ||
57795778
(TTI.getTriple().isAMDGPU() &&
57805779
!TTI.hasFeatureEnabled(TTI.getTargetOpts().FeatureMap, "clusters"))) {
5781-
S.Diag(AL.getLoc(), diag::err_cluster_attr_not_supported)
5782-
<< "__no_cluster__";
5780+
S.Diag(AL.getLoc(), diag::err_cluster_attr_not_supported) << AL;
57835781
return;
57845782
}
57855783

clang/test/SemaCUDA/cluster_dims.cu

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,52 @@
99
const int constint = 4;
1010

1111
// CHECK: __attribute__((global)) __attribute__((cluster_dims(2, 2, 2))) void test_literal_3d()
12-
__global__ void __cluster_dims__(2, 2, 2) test_literal_3d() {} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
12+
__global__ void __cluster_dims__(2, 2, 2) test_literal_3d() {} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
1313

1414
// CHECK: __attribute__((global)) __attribute__((cluster_dims(2, 2))) void test_literal_2d()
15-
__global__ void __cluster_dims__(2, 2) test_literal_2d() {} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
15+
__global__ void __cluster_dims__(2, 2) test_literal_2d() {} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
1616

1717
// CHECK: __attribute__((global)) __attribute__((cluster_dims(4))) void test_literal_1d()
18-
__global__ void __cluster_dims__(4) test_literal_1d() {} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
18+
__global__ void __cluster_dims__(4) test_literal_1d() {} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
1919

2020
// CHECK: __attribute__((global)) __attribute__((cluster_dims(constint, constint / 4, 1))) void test_constant()
21-
__global__ void __cluster_dims__(constint, constint / 4, 1) test_constant() {} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
21+
__global__ void __cluster_dims__(constint, constint / 4, 1) test_constant() {} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
2222

2323
// CHECK: template <int x, int y, int z> void test_template() __attribute__((cluster_dims(x, y, z)))
24-
template <int x, int y, int z> void test_template(void) __cluster_dims__(x, y, z){} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
24+
template <int x, int y, int z> void test_template(void) __cluster_dims__(x, y, z){} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
2525

2626
// CHECK: template <int x, int y, int z> void test_template_expr() __attribute__((cluster_dims(x + constint, y, z)))
27-
template <int x, int y, int z> void test_template_expr(void) __cluster_dims__(x + constint, y, z) {} //NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
27+
template <int x, int y, int z> void test_template_expr(void) __cluster_dims__(x + constint, y, z) {} //NS-error {{'cluster_dims' is not supported for this GPU architecture}}
2828

29-
//NS-error@+1 {{__cluster_dims__ is not supported for this GPU architecture}}
29+
//NS-error@+1 {{'cluster_dims' is not supported for this GPU architecture}}
3030
__global__ void __cluster_dims__(32, 2, 4) test_too_large_dim_0() {} // common-error {{integer constant expression evaluates to value 32 that cannot be represented in a 4-bit unsigned integer type}}
3131

3232
// cuda-error@+2 {{cluster does not support more than 8 thread blocks; 64 provided}}
3333
// amd-error@+1 {{cluster does not support more than 16 thread blocks; 64 provided}}
34-
__global__ void __cluster_dims__(4, 4, 4) test_too_large_dim_1() {} // NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
34+
__global__ void __cluster_dims__(4, 4, 4) test_too_large_dim_1() {} // NS-error {{'cluster_dims' is not supported for this GPU architecture}}
3535

3636
// cuda-error@+3 {{cluster does not support more than 8 thread blocks; 64 provided}}
3737
// amd-error@+2 {{cluster does not support more than 16 thread blocks; 64 provided}}
3838
template<unsigned a, unsigned b, unsigned c>
39-
__global__ void __cluster_dims__(a, b, c) test_too_large_dim_template() {} // NS-error {{__cluster_dims__ is not supported for this GPU architecture}}
39+
__global__ void __cluster_dims__(a, b, c) test_too_large_dim_template() {} // NS-error {{'cluster_dims' is not supported for this GPU architecture}}
4040
template __global__ void test_too_large_dim_template<4, 4, 4>(); // common-note {{in instantiation of function template specialization 'test_too_large_dim_template<4U, 4U, 4U>' requested here}}
4141

4242
int none_const_int = 4;
4343

44-
//NS-error@+1 {{__cluster_dims__ is not supported for this GPU architecture}}
44+
//NS-error@+1 {{'cluster_dims' is not supported for this GPU architecture}}
4545
__global__ void __cluster_dims__(none_const_int, 2, 4) test_non_constant_0() {} // common-error {{'cluster_dims' attribute requires parameter 0 to be an integer constant}}
4646

47-
//NS-error@+1 {{__cluster_dims__ is not supported for this GPU architecture}}
47+
//NS-error@+1 {{'cluster_dims' is not supported for this GPU architecture}}
4848
__global__ void __cluster_dims__(8, none_const_int / 2, 4) test_non_constant_1() {} // common-error {{'cluster_dims' attribute requires parameter 1 to be an integer constant}}
4949

50-
//NS-error@+1 {{__cluster_dims__ is not supported for this GPU architecture}}
50+
//NS-error@+1 {{'cluster_dims' is not supported for this GPU architecture}}
5151
__global__ void __cluster_dims__(8, 2, none_const_int / 4) test_non_constant_2() {} // common-error {{'cluster_dims' attribute requires parameter 2 to be an integer constant}}
5252

53-
//NS-error@+1 {{__no_cluster__ is not supported for this GPU architecture}}
53+
//NS-error@+1 {{'no_cluster' is not supported for this GPU architecture}}
5454
__global__ void __no_cluster__ test_no_cluster() {}
5555

56-
//NS-error@+2 {{__no_cluster__ is not supported for this GPU architecture}}
57-
//NS-error@+1 {{__cluster_dims__ is not supported for this GPU architecture}}
56+
//NS-error@+2 {{'no_cluster' is not supported for this GPU architecture}}
57+
//NS-error@+1 {{'cluster_dims' is not supported for this GPU architecture}}
5858
__global__ void __no_cluster__ __cluster_dims__(2,2,2) test_have_both() {} // common-error {{'cluster_dims' and 'no_cluster' attributes are not compatible}} common-note {{conflicting attribute is here}}
5959

6060
template <int... args>

0 commit comments

Comments
 (0)