aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wuse-after-free-3.c
blob: d1bcfcb3dda447e8581e8c1c032dcaf9baf624d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* PR middle-end/104232 - spurious -Wuse-after-free after conditional free
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

char* f (void);

static inline void freep (void *p)
{
  __builtin_free (*(void**)p);    // { dg-bogus "-Wuse-after-free" }
}

int test_no_warn (void)
{
  __attribute__ ((__cleanup__ (freep))) char *s = 0, *t = 0;

  t = f ();
  if (!t)
    return 0;

  s = f ();
  return 1;
}