aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-6.c
blob: f5507a361892625068c010c34db5be5f7b8d5f57 (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
33
34
35
36
37
/* { dg-require-effective-target sigsetjmp } */

#include "test-setjmp.h"
#include <stddef.h>
#include <stdlib.h>

extern int foo (int) __attribute__ ((__pure__));

static sigjmp_buf env;

static void inner (void)
{
  void *ptr = malloc (1024); /* { dg-message "allocated here" }  */

  siglongjmp (env, 1); /* { dg-warning "leak of 'ptr'" "warning" } */
  /* { dg-message "rewinding from 'siglongjmp' in 'inner'" " event: rewind from" { target *-*-* } .-1 } */

  free (ptr);
}

void outer (void)
{
  int i;

  foo (0);

  i = sigsetjmp(env, 0); /* { dg-message "'sigsetjmp' called here" "event: sigsetjmp call" } */
  /* { dg-message "to 'sigsetjmp' in 'outer'" "event: rewind to"  { target *-*-* } .-1 } */

  if (i == 0)
    {
      foo (1);
      inner ();
    }

  foo (3);
}