[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / warn-unsafe-buffer-usage-c-linkage.cpp
blob6c134098f87dfb98d17bd758206c4fde9f641dca
1 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -verify %s
3 extern "C" {
4 void foo(int *ptr) {
5 ptr[5] = 10; // expected-warning{{unsafe buffer access}}
8 void bar(int *ptr);
10 struct c_struct {
11 char *name;
15 void bar(int *ptr) {
16 ptr[5] = 10; // expected-warning{{unsafe buffer access}}
19 void 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);