aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/setjmp-2.c
blob: f5d9c53e2393e78cf2e3316985a0fe203860142a (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
/* { dg-require-effective-target indirect_jumps } */

#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"

extern void foo (int);

void test_1 (void)
{
  SETJMP (NULL);
}

void test_2 (void)
{
  jmp_buf env;
  int i;

  foo (0);

  i = SETJMP(env);

  foo (1);

  if (i != 0)
    {
      foo (2);
      __analyzer_dump_path (); /* { dg-message "path" } */
    }
  else
    longjmp (env, 1);

  foo (3);
}

/* { dg-begin-multiline-output "" }
   NN |       __analyzer_dump_path ();
      |       ^~~~~~~~~~~~~~~~~~~~~~~
  'test_2': event 1
    |
    |   NN |   i = SETJMP(env);
    |      |       ^~~~~~
    |      |       |
    |      |       (1) 'setjmp' called here
    |
  'test_2': events 2-4
    |
    |   NN |   if (i != 0)
    |      |      ^
    |      |      |
    |      |      (2) following 'false' branch (when 'i == 0')...
    |......
    |   NN |     longjmp (env, 1);
    |      |     ~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (3) ...to here
    |      |     (4) rewinding within 'test_2' from 'longjmp'...
    |
  'test_2': event 5
    |
    |   NN |   i = SETJMP(env);
    |      |       ^~~~~~
    |      |       |
    |      |       (5) ...to 'setjmp' (saved at (1))
    |
  'test_2': events 6-8
    |
    |   NN |   if (i != 0)
    |      |      ^
    |      |      |
    |      |      (6) following 'true' branch (when 'i != 0')...
    |   NN |     {
    |   NN |       foo (2);
    |      |       ~~~~~~~
    |      |       |
    |      |       (7) ...to here
    |   NN |       __analyzer_dump_path ();
    |      |       ~~~~~~~~~~~~~~~~~~~~~~~
    |      |       |
    |      |       (8) here
    |
    { dg-end-multiline-output "" } */

void test_3 (void)
{
  longjmp (NULL, 0);
}

void test_4 (void)
{
  longjmp (NULL, 1);
}

void test_5 (void)
{
  jmp_buf env;
  longjmp (env, 1);
}