aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/scope-1.c
blob: 7e53a1914c7e6c0644b06205bbc9ffb013bd470e (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
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */

#include <stdlib.h>

int test_1 (void)
{
  {
    int *q = (int *) malloc (1024);
  }

  return 42; /* { dg-warning "leak of 'q'" } */
  // FIXME: would be better to report it at the close-of-scope
}

int test_2 (void)
{
  {
    void *q = malloc (1024);
  }

  int q = 42;

  return q; /* { dg-warning "leak of 'q'" } */
  // FIXME: would be better to report it at the close-of-scope
}