| 1 |
struct foo |
| 2 |
{ |
| 3 |
char *expr; |
| 4 |
}; |
| 5 |
|
| 6 |
void |
| 7 |
test_1 (__UINTPTR_TYPE__ i) |
| 8 |
{ |
| 9 |
struct foo *f = (struct foo *)i; |
| 10 |
f->expr = (char *) __builtin_malloc (1024); |
| 11 |
} /* { dg-bogus "leak" } */ |
| 12 |
|
| 13 |
void |
| 14 |
test_2 (__UINTPTR_TYPE__ i) |
| 15 |
{ |
| 16 |
__builtin_free (((struct foo *)i)->expr); |
| 17 |
__builtin_free (((struct foo *)i)->expr); /* { dg-warning "double-'free' of '\\*\\(\\(struct foo \\*\\)i\\)\\.expr'" "" { target c } } */ |
| 18 |
/* { dg-warning "double-'free' of '\\*\\(\\(foo\\*\\)i\\)\\.foo::expr'" "" { target c++ } .-1 } */ |
| 19 |
} |
| 20 |
|
| 21 |
void |
| 22 |
test_3 (void *p) |
| 23 |
{ |
| 24 |
void **q = (void **)p; |
| 25 |
*q = __builtin_malloc (1024); |
| 26 |
} |