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