Skip to content

Commit f44e697

Browse files
committed
add warning flag for vector out of bounds warning. fix test
1 parent 656d6e8 commit f44e697

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ def SuperSubClassMismatch : DiagGroup<"super-class-method-mismatch">;
930930
def OverridingMethodMismatch : DiagGroup<"overriding-method-mismatch">;
931931
def VariadicMacros : DiagGroup<"variadic-macros">;
932932
def VectorConversion : DiagGroup<"vector-conversion">; // clang specific
933+
def VectorOutOfRange : DiagGroup<"vector-out-of-range">;
933934
def VexingParse : DiagGroup<"vexing-parse">;
934935
def VLAUseStaticAssert : DiagGroup<"vla-extension-static-assert">;
935936
def VLACxxExtension : DiagGroup<"vla-cxx-extension", [VLAUseStaticAssert]>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10638,7 +10638,8 @@ def err_sizeless_nonlocal : Error<
1063810638
def err_vector_index_out_of_range : Error<
1063910639
"vector element index %0 is out of bounds">;
1064010640
def warn_vector_index_out_of_range : Warning<
10641-
"vector element index %0 is out of bounds">;
10641+
"vector element index %0 is out of bounds">,
10642+
InGroup<VectorOutOfRange>, DefaultIgnore;
1064210643

1064310644
def err_vec_builtin_non_vector : Error<
1064410645
"%select{first two|all}1 arguments to %0 must be vectors">;

clang/test/SemaHLSL/Language/VectorOutOfRange-errors.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
export void fn1() {
44
int2 A = {1,2};
55
int X = A[-1];
6-
// expected-error@-1 {{vector element index '-1' is out of bounds}}
6+
// expected-error@-1 {{vector element index -1 is out of bounds}}
77
}
88

99
export void fn2() {
1010
int4 A = {1,2,3,4};
1111
int X = A[4];
12-
// expected-error@-1 {{vector element index '4' is out of bounds}}
12+
// expected-error@-1 {{vector element index 4 is out of bounds}}
1313
}
1414

1515
export void fn3() {
1616
bool2 A = {true,true};
1717
bool X = A[-1];
18-
// expected-error@-1 {{vector element index '-1' is out of bounds}}
18+
// expected-error@-1 {{vector element index -1 is out of bounds}}
1919
}

0 commit comments

Comments
 (0)