| 1 |
/* An example where the deallocator requires non-NULL. */ |
| 2 |
|
| 3 |
struct foo; |
| 4 |
extern void foo_release (struct foo *) |
| 5 |
__attribute__((nonnull)); |
| 6 |
extern struct foo *foo_acquire (void) |
| 7 |
__attribute__ ((malloc (foo_release))); |
| 8 |
|
| 9 |
void test_1 (void) |
| 10 |
{ |
| 11 |
struct foo *p = foo_acquire (); /* { dg-message "this call could return NULL" } */ |
| 12 |
foo_release (p); /* { dg-warning "use of possibly-NULL 'p' where non-null" } */ |
| 13 |
} |
| 14 |
|
| 15 |
void test_2 (void) |
| 16 |
{ |
| 17 |
struct foo *p = foo_acquire (); |
| 18 |
if (!p) |
| 19 |
return; |
| 20 |
foo_release (p); |
| 21 |
} |