gcc/testsuite/c-c++-common/analyzer/malloc-ipa-5.c
raw| 1 | /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ |
| 2 | |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | static int *calls_malloc(void) |
| 6 | { |
| 7 | return (int *) malloc(sizeof(int)); |
| 8 | } |
| 9 | |
| 10 | int *test(void) |
| 11 | { |
| 12 | int *p = calls_malloc(); /* { dg-message "possible return of NULL to 'test' from 'calls_malloc'" } */ |
| 13 | *p = 42; /* { dg-warning "dereference of possibly-NULL 'p'" } */ |
| 14 | return p; |
| 15 | } |