Skip to content

Commit b37f48f

Browse files
author
MalavikaSamak
committed
Add additional tests to check suppression in variadic functions and their callers.
1 parent 821a4b4 commit b37f48f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,19 @@ void check_no_warnings(unsigned idx) {
280280
A a;
281281
a.ptr = arr; // no-warning
282282
}
283+
284+
[[clang::unsafe_buffer_usage]]
285+
void check_no_warning_variadic(unsigned idx, int arr[20], ...) {
286+
int k = arr[idx]; // no-warning
287+
288+
std::span<int> sp = {arr, 20}; // no-warning
289+
A *ptr = reinterpret_cast<A*> (sp.data()); // no-warning
290+
A a;
291+
a.ptr = arr; // no-warning
292+
}
293+
294+
void invoke_methods() {
295+
int array[20];
296+
check_no_warnings(30); //expected-warning{{function introduces unsafe buffer manipulation}}
297+
check_no_warning_variadic(20, array); //expected-warning{{function introduces unsafe buffer manipulation}}
298+
}

0 commit comments

Comments
 (0)