@@ -295,6 +295,25 @@ void error_fseek(void) {
295295 fclose (F );
296296}
297297
298+ void error_fseeko (void ) {
299+ FILE * F = fopen ("file" , "r" );
300+ if (!F )
301+ return ;
302+ int rc = fseeko (F , 1 , SEEK_SET );
303+ if (rc ) {
304+ int IsFEof = feof (F ), IsFError = ferror (F );
305+ // Get feof or ferror or no error.
306+ clang_analyzer_eval (IsFEof || IsFError );
307+ // expected-warning@-1 {{FALSE}}
308+ // expected-warning@-2 {{TRUE}}
309+ clang_analyzer_eval (IsFEof && IsFError ); // expected-warning {{FALSE}}
310+ } else {
311+ clang_analyzer_eval (feof (F )); // expected-warning {{FALSE}}
312+ clang_analyzer_eval (ferror (F )); // expected-warning {{FALSE}}
313+ }
314+ fclose (F );
315+ }
316+
298317void error_fseek_0 (void ) {
299318 FILE * F = fopen ("file" , "r" );
300319 if (!F )
@@ -324,6 +343,68 @@ void error_fseek_0(void) {
324343 fclose (F );
325344}
326345
346+ void error_fseeko_0 (void ) {
347+ FILE * F = fopen ("file" , "r" );
348+ if (!F )
349+ return ;
350+ int rc = fseeko (F , 0 , SEEK_SET );
351+ if (rc ) {
352+ int IsFEof = feof (F ), IsFError = ferror (F );
353+ // Get ferror or no error, but not feof.
354+ clang_analyzer_eval (IsFError );
355+ // expected-warning@-1 {{FALSE}}
356+ // expected-warning@-2 {{TRUE}}
357+ clang_analyzer_eval (IsFEof );
358+ // expected-warning@-1 {{FALSE}}
359+ } else {
360+ clang_analyzer_eval (feof (F )); // expected-warning {{FALSE}}
361+ clang_analyzer_eval (ferror (F )); // expected-warning {{FALSE}}
362+ }
363+ fclose (F );
364+ }
365+
366+ void error_ftell (void ) {
367+ FILE * F = fopen ("file" , "r" );
368+ if (!F )
369+ return ;
370+ long rc = ftell (F );
371+ if (rc >= 0 )
372+ clang_analyzer_warnIfReached (); // expected-warning {{REACHABLE}}
373+ else
374+ clang_analyzer_eval (rc == -1 ); // expected-warning {{TRUE}}
375+ clang_analyzer_eval (feof (F ) && ferror (F )); // expected-warning {{FALSE}}
376+ StreamTesterChecker_make_feof_stream (F );
377+ rc = ftell (F );
378+ clang_analyzer_eval (feof (F )); // expected-warning {{TRUE}}
379+ clang_analyzer_eval (ferror (F )); // expected-warning {{FALSE}}
380+ StreamTesterChecker_make_ferror_stream (F );
381+ rc = ftell (F );
382+ clang_analyzer_eval (feof (F )); // expected-warning {{FALSE}}
383+ clang_analyzer_eval (ferror (F )); // expected-warning {{TRUE}}
384+ fclose (F );
385+ }
386+
387+ void error_ftello (void ) {
388+ FILE * F = fopen ("file" , "r" );
389+ if (!F )
390+ return ;
391+ off_t rc = ftello (F );
392+ if (rc >= 0 )
393+ clang_analyzer_warnIfReached (); // expected-warning {{REACHABLE}}
394+ else
395+ clang_analyzer_eval (rc == -1 ); // expected-warning {{TRUE}}
396+ clang_analyzer_eval (feof (F ) && ferror (F )); // expected-warning {{FALSE}}
397+ StreamTesterChecker_make_feof_stream (F );
398+ rc = ftello (F );
399+ clang_analyzer_eval (feof (F )); // expected-warning {{TRUE}}
400+ clang_analyzer_eval (ferror (F )); // expected-warning {{FALSE}}
401+ StreamTesterChecker_make_ferror_stream (F );
402+ rc = ftello (F );
403+ clang_analyzer_eval (feof (F )); // expected-warning {{FALSE}}
404+ clang_analyzer_eval (ferror (F )); // expected-warning {{TRUE}}
405+ fclose (F );
406+ }
407+
327408void error_fflush_after_fclose (void ) {
328409 FILE * F = tmpfile ();
329410 int Ret ;
0 commit comments