aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c
blob: ad536ce5f02f08cbfc7519adcb5aec1a5ee4791f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdlib.h>

void *
calls_malloc (void)
{
  void *result = malloc (1024);
  return result;
}

int *test_1 (int i)
{
  int *ptr = (int *)calls_malloc ();
  *ptr = i; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
  return ptr;
}

/* Same as test_1, to exercise the caches.  */

int *test_2 (int i)
{
  int *ptr = (int *)calls_malloc ();
  *ptr = i; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
  return ptr;
}