12 r
.ptr
= (int *) malloc (sizeof (int));
19 struct ptr_wrapper r
, s
;
20 r
.ptr
= (int *) malloc (sizeof (int));
34 n
.w
.ptr
= (int *) malloc (sizeof (int));
41 r
.ptr
= (int *) malloc (sizeof (int)); /* { dg-message "allocated here" } */
42 } /* { dg-warning "leak of 'r.ptr'" "" { target c } } */
43 /* { dg-warning "leak of 'r.ptr_wrapper::ptr'" "" { target c++ } .-1 } */
44 /* { dg-bogus "leak of '<unknown>'" "unknown leak" { target *-*-* } .-1 } */
46 static struct ptr_wrapper
__attribute__((noinline
))
47 called_by_test_5a (void)
50 r
.ptr
= (int *) malloc (sizeof (int)); /* { dg-message "allocated here" } */
56 struct ptr_wrapper q
= called_by_test_5a ();
57 } /* { dg-warning "leak of 'q.ptr'" "" { target c } } */
58 /* { dg-warning "leak of 'q.ptr_wrapper::ptr'" "" { target c++ } .-1 } */
60 static struct ptr_wrapper
__attribute__((noinline
))
61 called_by_test_5b (void)
64 r
.ptr
= (int *) malloc (sizeof (int));
65 return r
; /* { dg-warning "leak of '<return-value>.ptr'" "" { target c } } */
66 /* TODO: show the allocation point; improve above messages. C++ does show it. */
71 called_by_test_5b (); }
72 /* { dg-warning "leak of '<anonymous>.ptr_wrapper::ptr'" "" { target c++ } .-1 } */
73 /* The closing } above is intentionally on the same line as the call, because
74 otherwise the exact line of the diagnostics depends on whether the
75 called_by_test_5b () call satisfies aggregate_value_p or not. */