1 /* Example of interprocedural detection of an uninitialized field
2 in a heap-allocated struct. */
5 #include "analyzer-decls.h"
14 struct foo
*__attribute__((noinline
))
15 alloc_foo (int a
, int b
)
17 struct foo
*p
= malloc (sizeof (struct foo
)); /* { dg-message "region created on heap here" } */
25 void test_access_inited_fields (int x
, int y
, int z
)
27 struct foo
*p
= alloc_foo (x
, z
);
31 __analyzer_eval (p
->i
== x
); /* { dg-warning "TRUE" } */
33 __analyzer_eval (p
->k
== z
); /* { dg-warning "TRUE" } */
38 void test_stop_after_accessing_uninit (int x
, int y
, int z
)
40 struct foo
*p
= alloc_foo (x
, z
);
44 __analyzer_eval (p
->i
== x
); /* { dg-warning "TRUE" } */
46 __analyzer_eval (p
->j
== y
); /* { dg-warning "use of uninitialized value '\\*p\\.j'" } */
48 __analyzer_dump_path (); /* { dg-bogus "path" } */