152
|
1 /* Manual reimplemenation of <cstdlib>, to test name-matching within std. */
|
|
2
|
|
3 namespace std
|
|
4 {
|
|
5 typedef __SIZE_TYPE__ size_t;
|
|
6 void *malloc (std::size_t size);
|
|
7 void *calloc (std::size_t num, std::size_t size);
|
|
8 void free (void *ptr);
|
|
9 }
|
|
10
|
|
11 void test_1 (void *ptr)
|
|
12 {
|
|
13 std::free (ptr); /* { dg-message "first 'free' here" } */
|
|
14 std::free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */
|
|
15 }
|
|
16
|
|
17 void test_2 (void)
|
|
18 {
|
|
19 void *p = std::malloc (1024); /* { dg-message "allocated here" } */
|
|
20 } /* { dg-warning "leak of 'p'" } */
|
|
21
|
|
22 void test_3 (void)
|
|
23 {
|
|
24 void *p = std::calloc (42, 1024); /* { dg-message "allocated here" } */
|
|
25 } /* { dg-warning "leak of 'p'" } */
|