1 #include <stdlib.h> 2 #include "analyzer-decls.h" 3 4 struct foo 5 { 6 char *ptr; 7 }; 8 test_1(struct foo f)9void test_1 (struct foo f) 10 { 11 __analyzer_describe (0, f.ptr); /* { dg-warning "svalue: 'INIT_VAL\\(f.ptr\\)'" } */ 12 } 13 __analyzer_called_by_test_2(struct foo f_inner)14static void __analyzer_called_by_test_2 (struct foo f_inner) 15 { 16 free (f_inner.ptr); 17 free (f_inner.ptr); /* { dg-warning "double-'free' of 'f_outer.ptr'" } */ 18 } test_2(struct foo f_outer)19void test_2 (struct foo f_outer) 20 { 21 __analyzer_called_by_test_2 (f_outer); 22 } 23 24 struct nested 25 { 26 struct foo f; 27 }; 28 __analyzer_called_by_test_3(struct nested n_inner)29static void __analyzer_called_by_test_3 (struct nested n_inner) 30 { 31 free (n_inner.f.ptr); 32 free (n_inner.f.ptr); /* { dg-warning "double-'free' of 'n_outer.f.ptr'" } */ 33 } test_3(struct nested n_outer)34void test_3 (struct nested n_outer) 35 { 36 __analyzer_called_by_test_3 (n_outer); 37 } 38