Debian Codegraph @

gcc/testsuite/gcc.dg/Wfree-nonheap-object-7.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wfree-nonheap-object" } */
3
4 struct local_caches *get_local_caches_lcs;
5 void *calloc(__SIZE_TYPE__, __SIZE_TYPE__);
6 void *realloc(void *, __SIZE_TYPE__);
7
8 struct local_caches {
9 int *t_mem_caches;
10 };
11
12 struct local_caches *get_local_caches() {
13 if (get_local_caches_lcs)
14 return get_local_caches_lcs;
15 get_local_caches_lcs = calloc(1, 0);
16 return get_local_caches_lcs;
17 }
18
19 void libtrace_ocache_free() {
20 struct local_caches lcs = *get_local_caches(), __trans_tmp_1 = lcs;
21 {
22 struct local_caches *lcs = &__trans_tmp_1;
23 lcs->t_mem_caches += 10;
24 __trans_tmp_1.t_mem_caches = realloc(__trans_tmp_1.t_mem_caches, sizeof(int)); // { dg-warning "called on pointer (?:(?!PHI).)*nonzero offset" }
25 }
26 }