aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/edges-2.c
blob: 7e4543c24c30faab022383343a27a7a658539027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */

#include <stdlib.h>

int foo ();
int bar ();

/* Verify that only significant edges are reported.  */

void test (int a, int b, int c)
{
  void *p = malloc (1024); /* { dg-message "allocated here" } */
  while (a) /* { dg-bogus "" } */
    foo ();
  if (b) /* { dg-bogus "" } */
    foo ();
  else
    bar ();
  if (c) /* { dg-message "following 'true' branch" } */
    free (p); /* { dg-message "first 'free' here" } */
  free (p); /* { dg-warning "double-'free' of 'p'" } */
}