analyzer: Fix PR analyzer/101980
[official-gcc.git] / gcc / testsuite / gcc.dg / analyzer / setjmp-2.c
blobf5d9c53e2393e78cf2e3316985a0fe203860142a
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 } */
5 #include "test-setjmp.h"
6 #include <stddef.h>
7 #include "analyzer-decls.h"
9 extern void foo (int);
11 void test_1 (void)
13 SETJMP (NULL);
16 void test_2 (void)
18 jmp_buf env;
19 int i;
21 foo (0);
23 i = SETJMP(env);
25 foo (1);
27 if (i != 0)
29 foo (2);
30 __analyzer_dump_path (); /* { dg-message "path" } */
32 else
33 longjmp (env, 1);
35 foo (3);
38 /* { dg-begin-multiline-output "" }
39 NN | __analyzer_dump_path ();
40 | ^~~~~~~~~~~~~~~~~~~~~~~
41 'test_2': event 1
43 | NN | i = SETJMP(env);
44 | | ^~~~~~
45 | | |
46 | | (1) 'setjmp' called here
48 'test_2': events 2-4
50 | NN | if (i != 0)
51 | | ^
52 | | |
53 | | (2) following 'false' branch (when 'i == 0')...
54 |......
55 | NN | longjmp (env, 1);
56 | | ~~~~~~~~~~~~~~~~
57 | | |
58 | | (3) ...to here
59 | | (4) rewinding within 'test_2' from 'longjmp'...
61 'test_2': event 5
63 | NN | i = SETJMP(env);
64 | | ^~~~~~
65 | | |
66 | | (5) ...to 'setjmp' (saved at (1))
68 'test_2': events 6-8
70 | NN | if (i != 0)
71 | | ^
72 | | |
73 | | (6) following 'true' branch (when 'i != 0')...
74 | NN | {
75 | NN | foo (2);
76 | | ~~~~~~~
77 | | |
78 | | (7) ...to here
79 | NN | __analyzer_dump_path ();
80 | | ~~~~~~~~~~~~~~~~~~~~~~~
81 | | |
82 | | (8) here
84 { dg-end-multiline-output "" } */
86 void test_3 (void)
88 longjmp (NULL, 0);
91 void test_4 (void)
93 longjmp (NULL, 1);
96 void test_5 (void)
98 jmp_buf env;
99 longjmp (env, 1);