1 /* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
2 /* { dg-enable-nn-line-numbers "" } */
3 
4 #include "test-setjmp.h"
5 #include "analyzer-decls.h"
6 
7 extern int foo (int) __attribute__ ((__pure__));
8 static jmp_buf buf;
9 
inner(int x)10 void inner (int x)
11 {
12   foo (x);
13   longjmp (buf, 1);
14   foo (x);
15 }
16 
outer(int y)17 void outer (int y)
18 {
19   foo (y);
20   inner (y);
21   foo (y);
22 }
23 
main(void)24 int main (void)
25 {
26   if (!SETJMP(buf))
27     outer (42);
28   else
29     __analyzer_dump_path (); /* { dg-message "path" } */
30   return 0;
31 }
32 
33 /* { dg-begin-multiline-output "" }
34    NN |     __analyzer_dump_path ();
35       |     ^~~~~~~~~~~~~~~~~~~~~~~
36   'main': event 1
37     |
38     |   NN | int main (void)
39     |      |     ^~~~
40     |      |     |
41     |      |     (1) entry to 'main'
42     |
43   'main': event 2
44     |
45     |   NN |   if (!SETJMP(buf))
46     |      |        ^~~~~~
47     |      |        |
48     |      |        (2) 'setjmp' called here
49     |
50   'main': events 3-5
51     |
52     |   NN |   if (!SETJMP(buf))
53     |      |      ^
54     |      |      |
55     |      |      (3) following 'true' branch...
56     |   NN |     outer (42);
57     |      |     ~~~~~~~~~~
58     |      |     |
59     |      |     (4) ...to here
60     |      |     (5) calling 'outer' from 'main'
61     |
62     +--> 'outer': events 6-7
63            |
64            |   NN | void outer (int y)
65            |      |      ^~~~~
66            |      |      |
67            |      |      (6) entry to 'outer'
68            |......
69            |   NN |   inner (y);
70            |      |   ~~~~~~~~~
71            |      |   |
72            |      |   (7) calling 'inner' from 'outer'
73            |
74            +--> 'inner': events 8-9
75                   |
76                   |   NN | void inner (int x)
77                   |      |      ^~~~~
78                   |      |      |
79                   |      |      (8) entry to 'inner'
80                   |......
81                   |   NN |   longjmp (buf, 1);
82                   |      |   ~~~~~~~~~~~~~~~~
83                   |      |   |
84                   |      |   (9) rewinding from 'longjmp' in 'inner'...
85                   |
86     <-------------+
87     |
88   'main': event 10
89     |
90     |   NN |   if (!SETJMP(buf))
91     |      |        ^~~~~~
92     |      |        |
93     |      |        (10) ...to 'setjmp' in 'main' (saved at (2))
94     |
95   'main': events 11-13
96     |
97     |   NN |   if (!SETJMP(buf))
98     |      |      ^
99     |      |      |
100     |      |      (11) following 'false' branch...
101     |......
102     |   NN |     __analyzer_dump_path ();
103     |      |     ~~~~~~~~~~~~~~~~~~~~~~~
104     |      |     |
105     |      |     (12) ...to here
106     |      |     (13) here
107     |
108     { dg-end-multiline-output "" } */
109 
110