aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-7.c
blob: 0742370d2f91d776c7c060603381fe58a2843c27 (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
26
27
28
29
#include <stdlib.h>

/**************************************************************************/

static void maybe_calls_free_1(int *q, int flag)
{
  if (flag)
    free(q); /* { dg-warning "double-'free' of 'q'" } */
}

void test_1(void *p)
{
  maybe_calls_free_1(p, 1);
  maybe_calls_free_1(p, 1); 
}

/**************************************************************************/

static void maybe_calls_free_2(int *q, int flag)
{
  if (flag)
    free(q); /* { dg-bogus "double-'free'" } */
}

void test_2(void *p)
{
  maybe_calls_free_2(p, 0);
  maybe_calls_free_2(p, 0);
}