aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/pr97074.c
blob: ccb3b61bd415b2836e7d5b359add8349bf3ab70c (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
25
26
27
28
29
30
31
32
#include "analyzer-decls.h"
#define NULL ((void *)0)

void *x, *y;

void test_1 (int flag)
{
  void *p = __builtin_malloc (1024);
  if (flag)
    x = p;
  else
    y = p;
} /* { dg-bogus "leak" } */

struct s2
{
  void *f1;
  void *f2;
};

struct s2 test_2 (int flag)
{
  struct s2 r;
  r.f1 = NULL;
  r.f2 = NULL;
  void *p = __builtin_malloc (1024);
  if (flag)
    r.f1 = p;
  else
    r.f2 = p;
  return r;
}