gcc/testsuite/gcc.dg/analyzer/data-model-13.c
raw| 1 | #include <stdlib.h> |
| 2 | |
| 3 | union |
| 4 | { |
| 5 | void *ptr_val; |
| 6 | int int_val; |
| 7 | } global_union; |
| 8 | |
| 9 | void test_1 (void) |
| 10 | { |
| 11 | global_union.ptr_val = malloc (1024); |
| 12 | } |
| 13 | |
| 14 | void test_2 (void) |
| 15 | { |
| 16 | global_union.ptr_val = malloc (1024); /* { dg-message "allocated here" } */ |
| 17 | global_union.int_val = 0; /* { dg-warning "leak of 'global_union.ptr_val' " } */ |
| 18 | } |