1 /* { dg-additional-options "-fanalyzer-transitivity" } */ 2 3 #include <stdlib.h> 4 #include "analyzer-decls.h" 5 test_1(int a,int b)6int test_1 (int a, int b) 7 { 8 void *p; 9 10 if (a > 5) 11 if (b) 12 p = malloc (16); 13 else 14 p = malloc (32); 15 16 __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */ 17 18 if (a > 5) 19 { 20 free (p); 21 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ 22 } 23 24 return 0; /* { dg-bogus "leak" } */ 25 } 26 test_2(int a,int b)27int test_2 (int a, int b) 28 { 29 void *p; 30 31 if (a > 5) 32 if (b) 33 p = malloc (16); 34 else 35 p = malloc (32); 36 37 __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */ 38 39 if (a > 6) /* different condition */ 40 { 41 free (p); 42 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ 43 } 44 45 return 0; /* { dg-warning "leak of 'p'" } */ 46 /* leaks when a == 5. */ 47 } 48