Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/isatty-1.c

raw
1 /* { dg-skip-if "" { powerpc*-*-aix* } } */
2 /* { dg-skip-if "" { "avr-*-*" } } */
3
4 #include <errno.h>
5 #include "../../gcc.dg/analyzer/analyzer-decls.h"
6
7 extern int isatty(int fd);
8 extern int close(int fd);
9
10 int test_pass_through (int fd)
11 {
12 return isatty (fd);
13 }
14
15 void test_merging (int fd)
16 {
17 isatty (fd);
18 __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
19 }
20
21 int test_outcomes (int fd)
22 {
23 errno = 0;
24 int result = isatty (fd);
25 switch (result)
26 {
27 default:
28 __analyzer_dump_path (); /* { dg-bogus "path" } */
29 break;
30 case 0:
31 __analyzer_dump_path (); /* { dg-message "path" } */
32 __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
33 break;
34 case 1:
35 __analyzer_dump_path (); /* { dg-message "path" } */
36 __analyzer_eval (errno == 0); /* { dg-warning "TRUE" } */
37 break;
38 }
39 return result;
40 }
41
42 int test_isatty_on_invalid_fd (void)
43 {
44 errno = 0;
45 int result = isatty (-1);
46 __analyzer_eval (result == 0); /* { dg-warning "TRUE" } */
47 __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
48 return result;
49 }
50
51 int test_isatty_on_closed_fd (int fd)
52 {
53 close (fd);
54 errno = 0;
55 int result = isatty (fd);
56 __analyzer_eval (result == 0); /* { dg-warning "TRUE" } */
57 __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
58 return result;
59 }