| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ |
| 2 |
|
| 3 |
/* Verify that we emit sane paths for state machine errors. */ |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
int *test_3 (void) |
| 8 |
{ |
| 9 |
int *ptr = (int *)malloc (sizeof (int)); /* { dg-line malloc } */ |
| 10 |
*ptr = 42; /* { dg-line unchecked_deref } */ |
| 11 |
return ptr; |
| 12 |
|
| 13 |
/* { dg-warning "dereference of possibly-NULL 'ptr'" "warning" { target *-*-* } unchecked_deref } */ |
| 14 |
/* { dg-message "\\(1\\) this call could return NULL" "event 1" { target *-*-* } malloc } */ |
| 15 |
/* { dg-message "\\(2\\) 'ptr' could be NULL" "event 2" { target *-*-* } unchecked_deref } */ |
| 16 |
} |