Skip to content

Commit 4c95972

Browse files
committed
Update warn-unsafe-buffer-usage-debug-unclaimed.cpp
1 parent 800d393 commit 4c95972

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clang/test/SemaCXX/warn-unsafe-buffer-usage-debug-unclaimed/warn-unsafe-buffer-usage-debug-unclaimed.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ void test_unclaimed_use(int *p) { // expected-warning{{'p' is an unsafe pointer
3232
p[5] = 5; // expected-note{{used in buffer access here}}
3333
}
3434

35+
namespace std {
36+
inline namespace __1 {
37+
template <class T> class unique_ptr {
38+
public:
39+
T &operator[](long long i) const;
40+
};
41+
} // namespace __1
42+
} // namespace std
43+
44+
void basic_unique_ptr() {
45+
std::unique_ptr<int[]> p1;
46+
p1[0]; // expected-warning{{direct access using operator[] on
47+
// std::unique_ptr<T[]> is unsafe due to lack of bounds checking}}
48+
}
49+
3550
// CHECK: Root # 1
3651
// CHECK: |- DeclRefExpr # 4
3752
// CHECK: |-- UnaryOperator(++) # 1

0 commit comments

Comments
 (0)