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 test_1(void)12void 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" "desired" { xfail *-*-* } } */ 18 /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */ 19 free (f); 20 } 21 22 /* TODO: verify that we know the behavior of memset. */ 23 test_2(void)24void test_2 (void) 25 { 26 struct foo *f = malloc (sizeof (struct foo)); 27 if (f == NULL) 28 return; 29 memset (f, 0, sizeof (struct foo)); 30 __analyzer_eval (f->i == 0); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */ 31 /* { dg-bogus "UNKNOWN" "status quo" { xfail *-*-* } .-1 } */ 32 free (f); 33 } 34