balazske added a comment. The following test is not good in place of the 3rd? It is nearly the same, only the condition `(!ferror(F) && !feof(F))` is used instead of call to `clearerr`.
void check_indeterminate_notes_fseek_no_feof_no_ferror() { FILE *F; char Buf[10]; F = fopen("foo1.c", "r"); if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is non-null}} return; fseek(F, 1, SEEK_SET); // expected-note {{Assuming this stream operation fails}} if (!ferror(F) && !feof(F)) // expected-note {{Taking true branch}} // expected-note {{Left side of '&&' is true}} fread(Buf, 1, 1, F); // expected-warning {{File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior}} // expected-note@-1 {{File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior}} fclose(F); } The condition can be changed to `feof(F)` or `ferror(F)` to change the bug type and the note message at `fseek`. The following test is good too to test if the message depends on the bug type (note check comments are not included): void check_notes_fseek() { FILE *F; char Buf[10]; F = fopen("foo1.c", "r"); if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is non-null}} return; fseek(F, 1, SEEK_SET); fread(Buf, 1, 1, F); // expected-warning {{File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior [alpha.unix.Stream]}} // expected-warning@-1 {{Read function called when stream is in EOF state. Function has no effect [alpha.unix.Stream]}} fclose(F); } Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106262/new/ https://reviews.llvm.org/D106262 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits