25 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -verify %s2 3extern "C" {4void foo(int *ptr) {5 ptr[5] = 10; // expected-warning{{unsafe buffer access}}6}7 8void bar(int *ptr);9 10struct c_struct {11 char *name;12};13}14 15void bar(int *ptr) {16 ptr[5] = 10; // expected-warning{{unsafe buffer access}}17}18 19void call_foo(int *p) {20 foo(p);21 struct c_struct str;22 str.name[7] = 9; // expected-warning{{unsafe buffer access}}23 bar(p);24}25