================
@@ -268,3 +302,20 @@ void error_indeterminate_feof2(void) {
   }
   fclose(F);
 }
+
+void error_indeterminate_feof3(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+    return;
+  char Buf[10];
+  if (fread(Buf, 1, 10, F) < 10) {
+    if (feof(F)) {
+      // error is feof, should be non-indeterminate
+      fputc(';', F); // no warning
+    }
+    if (ferror(F)) {
+      fputc('=', F); // expected-warning {{might be 'indeterminate'}}
+    }
+  }
+  fclose(F);
+}
----------------
balazske wrote:

I think that these 2 added "indeterminate" tests should be combined into one, 
or this last can be removed. The tests called `error_indeterminate_eof` have 
the role to test when the stream becomes indeterminate (or not) and use the 
function `fwrite` only to check for the presence of indeterminate state, not to 
test `fwrite` itself. So it is not necessary to repeat similar tests with 
`fputc`. But a test is needed to check if a warning for indeterminate state is 
produced by `fputc` in the correct cases, and no warnings for EOF, the function 
`error_indeterminate_fputc` does this already.

It would be better if there would be new debug functions in the checker that 
can get if the stream is "indeterminate" and one that can be used to set values 
of indeterminate, ferror, feof in a stream. Then the tests can be simplified. 
But this is only an idea for another PR, probably I will do this later.

https://github.com/llvm/llvm-project/pull/71518
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to