mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 13:36:08 +00:00

Lifetimebound annotations can help diagnose common cases of dangling including escaping the address of a stack variable from a function. This is useful in all C family languages, restricting these diagnostics to C++ is an artificial limitation. Co-authored-by: Gabor Horvath <gaborh@apple.com>
9 lines
218 B
C
9 lines
218 B
C
// RUN: %clang_cc1 -std=c99 -verify %s
|
|
|
|
int *f(int* p __attribute__((lifetimebound)));
|
|
|
|
int *g() {
|
|
int i;
|
|
return f(&i); // expected-warning {{address of stack memory associated with local variable 'i' returned}}
|
|
}
|