1 #include "analyzer-decls.h"
2
3 extern int errno;
4
5 extern void error (int __status, int __errnum, const char *__format, ...)
6 __attribute__ ((__format__ (__printf__, 3, 4)));
7
8 extern void error_at_line (int __status, int __errnum, const char *__fname,
9 unsigned int __lineno, const char *__format, ...)
10 __attribute__ ((__format__ (__printf__, 5, 6)));
11
12 /* When status is an unknown param. */
13
test_1(int st)14 void test_1 (int st)
15 {
16 error (st, errno, "test");
17 __analyzer_eval (st == 0); /* { dg-warning "TRUE" } */
18 }
19
20 /* When status is known zero. */
21
test_2(int st)22 void test_2 (int st)
23 {
24 error (0, errno, "test");
25 __analyzer_dump_path (); /* { dg-message "here" } */
26 }
27
28 /* When status is a non-zero known constant. */
29
test_3(int st)30 void test_3 (int st)
31 {
32 error (1, errno, "test");
33 __analyzer_dump_path (); /* { dg-bogus "here" } */
34 }
35
36 /* When status has been tested against zero. */
37
test_4(int st)38 void test_4 (int st)
39 {
40 if (st)
41 {
42 error (st, errno, "nonzero branch");
43 __analyzer_dump_path (); /* { dg-bogus "here" } */
44 }
45 else
46 {
47 error (st, errno, "zero branch");
48 __analyzer_dump_path (); /* { dg-message "here" } */
49 }
50 }
51
52 /* Similarly for error_at_line. */
53
test_5(int st)54 void test_5 (int st)
55 {
56 error_at_line (st, errno, __FILE__, __LINE__, "test");
57 __analyzer_eval (st == 0); /* { dg-warning "TRUE" } */
58 }
59
60 /* Non-trivial format string. */
61
test_6(int st,const char * str)62 void test_6 (int st, const char *str)
63 {
64 error (st, errno, "test: %s", str);
65 __analyzer_eval (st == 0); /* { dg-warning "TRUE" } */
66 }
67