1  /* Verify that we emit sane paths for state machine errors.  */
       2  
       3  #include <stdlib.h>
       4  
       5  int *test_4 (void)
       6  {
       7    int *ptr = (int *)malloc (sizeof (int)); /* { dg-line malloc } */
       8    if (ptr) /* { dg-line cond } */
       9      *ptr = 42;
      10    else
      11      *ptr = 43; /* { dg-line on_null_ptr } */
      12    return ptr;
      13  
      14    /* { dg-warning "dereference of NULL 'ptr'" "warning" { target *-*-* } on_null_ptr } */
      15    /* { dg-message "\\(1\\) allocated here" "event 1" { target *-*-* } malloc } */
      16    /* { dg-message "\\(2\\) assuming 'ptr' is NULL" "event 2" { target *-*-* } cond } */
      17    /* { dg-message "\\(3\\) following 'false' branch \\(when 'ptr' is NULL\\)\\.\\.\\." "event 3" { target *-*-* } cond } */
      18    /* { dg-message "\\(4\\) \\.\\.\\.to here" "event 4" { target *-*-* } on_null_ptr } */
      19    /* { dg-message "\\(5\\) dereference of NULL 'ptr'" "event 5" { target *-*-* } on_null_ptr } */
      20  }