Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/scope-1.c

raw
1 /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */
2
3 #include <stdlib.h>
4
5 int test_1 (void)
6 {
7 {
8 int *q = (int *) malloc (1024);
9 }
10
11 return 42; /* { dg-warning "leak of 'q'" } */
12 // FIXME: would be better to report it at the close-of-scope
13 }
14
15 int test_2 (void)
16 {
17 {
18 void *q = malloc (1024);
19 }
20
21 int q = 42;
22
23 return q; /* { dg-warning "leak of 'q'" } */
24 // FIXME: would be better to report it at the close-of-scope
25 }