aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c
blob: 8f9e4cff6e2b26a95d054d2b36ac2ccf80e4fb16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Verify that we emit sane paths for state machine errors.  */

#include <stdlib.h>

int *test_3 (void)
{
  int *ptr = (int *)malloc (sizeof (int)); /* { dg-line malloc } */
  *ptr = 42; /* { dg-line unchecked_deref } */
  return ptr;

  /* { dg-warning "dereference of possibly-NULL 'ptr'" "warning" { target *-*-* } unchecked_deref } */
  /* { dg-message "\\(1\\) this call could return NULL" "event 1" { target *-*-* } malloc } */
  /* { dg-message "\\(2\\) 'ptr' could be NULL" "event 2" { target *-*-* } unchecked_deref } */
}