| 1 |
#include <stdlib.h> |
| 2 |
#include <string.h> |
| 3 |
#include "analyzer-decls.h" |
| 4 |
|
| 5 |
struct foo |
| 6 |
{ |
| 7 |
int i; |
| 8 |
}; |
| 9 |
|
| 10 |
/* TODO: verify that we know that calloc zeros its memory. */ |
| 11 |
|
| 12 |
void test_1 (void) |
| 13 |
{ |
| 14 |
struct foo *f = calloc (1, sizeof (struct foo)); |
| 15 |
if (f == NULL) |
| 16 |
return; |
| 17 |
__analyzer_eval (f->i == 0); /* { dg-warning "TRUE" } */ |
| 18 |
free (f); |
| 19 |
} |
| 20 |
|
| 21 |
/* TODO: verify that we know the behavior of memset. */ |
| 22 |
|
| 23 |
void test_2 (void) |
| 24 |
{ |
| 25 |
struct foo *f = malloc (sizeof (struct foo)); |
| 26 |
if (f == NULL) |
| 27 |
return; |
| 28 |
memset (f, 0, sizeof (struct foo)); |
| 29 |
__analyzer_eval (f->i == 0); /* { dg-warning "TRUE" } */ |
| 30 |
free (f); |
| 31 |
} |