llvm-project/clang/test/Sema/attr-lifetimebound.c
Gábor Horváth 8b29c05b73
[clang] Permit lifetimebound in all language modes (#115482)
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>
2024-11-08 15:05:11 +00:00

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}}
}