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