| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
|
| 5 |
/**************************************************************************/ |
| 6 |
|
| 7 |
static void maybe_calls_free_1(int *q, int flag) |
| 8 |
{ |
| 9 |
if (flag) |
| 10 |
free(q); /* { dg-warning "double-'free' of 'q'" } */ |
| 11 |
} |
| 12 |
|
| 13 |
void test_1(void *p) |
| 14 |
{ |
| 15 |
maybe_calls_free_1((int *) p, 1); |
| 16 |
maybe_calls_free_1((int *) p, 1); |
| 17 |
} |
| 18 |
|
| 19 |
/**************************************************************************/ |
| 20 |
|
| 21 |
static void maybe_calls_free_2(int *q, int flag) |
| 22 |
{ |
| 23 |
if (flag) |
| 24 |
free(q); /* { dg-bogus "double-'free'" } */ |
| 25 |
} |
| 26 |
|
| 27 |
void test_2(void *p) |
| 28 |
{ |
| 29 |
maybe_calls_free_2((int *) p, 0); |
| 30 |
maybe_calls_free_2((int *) p, 0); |
| 31 |
} |