[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / clang / test / Analysis / stackaddrleak.cpp
blob3daffb35a6cd9a61b4572db4be21d35a719b7081
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
3 using size_t = decltype(sizeof(int));
4 void *operator new(size_t, void *p) { return p; }
6 struct myfunction {
7 union storage_t {
8 char buffer[100];
9 size_t max_align;
10 } storage;
12 template <typename Func> myfunction(Func fn) {
13 new (&storage.buffer) Func(fn);
15 void operator()();
18 myfunction create_func() {
19 int n;
20 auto c = [&n] {};
21 return c; // expected-warning {{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}}
23 void gh_66221() {
24 create_func()();