blob: 0b5304ea6d0507e0551068832f1d37229074e1f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* { dg-additional-options "-fanalyzer-verbosity=1" } */
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */
#include <stdlib.h>
void
calls_free (void *victim)
{
free (victim); /* { dg-warning "double-'free' of 'victim'" } */
}
extern void do_stuff (void);
struct foo
{
void *m_p;
};
static void * __attribute__((noinline))
test_a (struct foo f)
{
do_stuff ();
calls_free (f.m_p);
do_stuff ();
return f.m_p;
}
void test_b (void *p)
{
void *q;
struct foo f;
f.m_p = p;
q = test_a (f);
calls_free (q); /* { dg-message "passing freed pointer 'q' in call to 'calls_free' from 'test_b'" } */
do_stuff ();
}
|