1 // RUN: %clang_analyze_cc1 -triple=x86_64-pc-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \
2 // RUN: -analyzer-config unix.Stream:Pedantic=false -verify=nopedantic %s
4 // RUN: %clang_analyze_cc1 -triple=x86_64-pc-linux-gnu -analyzer-checker=core,unix.Stream,debug.ExprInspection \
5 // RUN: -analyzer-config unix.Stream:Pedantic=true -verify=pedantic %s
7 #include "Inputs/system-header-simulator.h"
9 void clang_analyzer_eval(int);
11 void check_fwrite(void) {
12 char *Buf
= "123456789";
16 size_t Ret
= fwrite(Buf
, 1, 10, Fp
);
17 clang_analyzer_eval(Ret
== 0); // nopedantic-warning {{FALSE}} \
18 // pedantic-warning {{FALSE}} \
19 // pedantic-warning {{TRUE}}
20 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
24 void check_fputc(void) {
28 int Ret
= fputc('A', Fp
);
29 clang_analyzer_eval(Ret
== EOF
); // nopedantic-warning {{FALSE}} \
30 // pedantic-warning {{FALSE}} \
31 // pedantic-warning {{TRUE}}
32 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
36 void check_fputs(void) {
40 int Ret
= fputs("ABC", Fp
);
41 clang_analyzer_eval(Ret
== EOF
); // nopedantic-warning {{FALSE}} \
42 // pedantic-warning {{FALSE}} \
43 // pedantic-warning {{TRUE}}
44 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
48 void check_fprintf(void) {
52 int Ret
= fprintf(Fp
, "ABC");
53 clang_analyzer_eval(Ret
< 0); // nopedantic-warning {{FALSE}} \
54 // pedantic-warning {{FALSE}} \
55 // pedantic-warning {{TRUE}}
56 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
60 void check_fseek(void) {
64 int Ret
= fseek(Fp
, 0, 0);
65 clang_analyzer_eval(Ret
== -1); // nopedantic-warning {{FALSE}} \
66 // pedantic-warning {{FALSE}} \
67 // pedantic-warning {{TRUE}}
68 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
72 void check_fseeko(void) {
76 int Ret
= fseeko(Fp
, 0, 0);
77 clang_analyzer_eval(Ret
== -1); // nopedantic-warning {{FALSE}} \
78 // pedantic-warning {{FALSE}} \
79 // pedantic-warning {{TRUE}}
80 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}
84 void check_fsetpos(void) {
89 int Ret
= fsetpos(Fp
, &Pos
);
90 clang_analyzer_eval(Ret
); // nopedantic-warning {{FALSE}} \
91 // pedantic-warning {{FALSE}} \
92 // pedantic-warning {{TRUE}}
93 fputc('A', Fp
); // pedantic-warning {{might be 'indeterminate'}}