1 #include "analyzer-decls.h"
5 __analyzer_dump_path (); /* { dg-message "path" } */
11 __analyzer_dump_path (); /* { dg-message "path" } */
14 void test_3 (int flag
)
18 __analyzer_dump_path (); /* { dg-bogus "path" } */
21 int global_for_test_4
;
22 static void __attribute__((noinline
)) called_by_test_4 () {}
25 /* Verify that a state change that happens in a stmt that
26 isn't the first within its BB can affect path feasibility. */
27 global_for_test_4
= 0;
28 global_for_test_4
= 1;
29 /* Thwart the optimizer. */
31 if (global_for_test_4
)
32 __analyzer_dump_path (); /* { dg-message "path" } */
35 /* Verify that loops don't confuse the feasibility checker. */
39 for (int i
= 0; i
< 1024; i
++)
42 __analyzer_dump_path (); /* { dg-message "path" } */
45 /* Reproducer for an issue seen with CVE-2005-1689 (PR analyzer/96374): if we
46 take the shortest path and update state and check feasibility per-edge, we
47 can erroneously reject valid diagnostics. */
49 int test_6 (int a
, int b
)
58 __analyzer_dump_path (); /* { dg-message "path" } */
63 /* As above, but call a static function.
64 Even if the path to the call of called_by_test_6a is falsely rejected
65 as infeasible, it still makes sense to complain about errors within
66 the called function. */
68 static void __attribute__((noinline
))
69 called_by_test_6a (void *ptr
)
72 __builtin_free (ptr
); /* { dg-message "double-'free'" } */
75 int test_6a (int a
, int b
, void *ptr
)
84 called_by_test_6a (ptr
);
89 /* After state-merging, the shortest path skips the loop,
90 but the shortest feasible path enters it. */
96 for (i
= 0; i
< n
; i
++)
99 __analyzer_dump_path (); /* { dg-message "path" } */