comparison gcc/testsuite/g++.dg/analyzer/cstdlib-2.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
145:1830386684a0 152:2b5abeee2509
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'" } */