| 1 |
/* Verify that we check for uninitialized values passed to functions |
| 2 |
that we have special-cased state-machine handling for. */ |
| 3 |
|
| 4 |
typedef struct FILE FILE; |
| 5 |
|
| 6 |
FILE* fopen (const char*, const char*); |
| 7 |
int fclose (FILE*); |
| 8 |
int fseek (FILE *, long, int); |
| 9 |
|
| 10 |
FILE * |
| 11 |
test_fopen_uninit_path (void) |
| 12 |
{ |
| 13 |
const char *path; |
| 14 |
FILE *f = fopen (path, "r"); /* { dg-warning "use of uninitialized value 'path'" } */ |
| 15 |
return f; |
| 16 |
} |
| 17 |
|
| 18 |
FILE * |
| 19 |
test_fopen_uninit_mode (const char *path) |
| 20 |
{ |
| 21 |
const char *mode; |
| 22 |
FILE *f = fopen (path, mode); /* { dg-warning "use of uninitialized value 'mode'" } */ |
| 23 |
return f; |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
test_fclose_uninit (void) |
| 28 |
{ |
| 29 |
FILE *f; |
| 30 |
fclose (f); /* { dg-warning "use of uninitialized value 'f'" } */ |
| 31 |
} |
| 32 |
|
| 33 |
int |
| 34 |
test_fseek_uninit_stream (void) |
| 35 |
{ |
| 36 |
FILE *stream; |
| 37 |
return fseek (stream, 0, 0); /* { dg-warning "use of uninitialized value 'stream'" } */ |
| 38 |
} |
| 39 |
|
| 40 |
int |
| 41 |
test_fseek_uninit_offset (FILE *stream, int whence) |
| 42 |
{ |
| 43 |
long offset; |
| 44 |
return fseek (stream, offset, whence); /* { dg-warning "use of uninitialized value 'offset'" } */ |
| 45 |
} |
| 46 |
|
| 47 |
int |
| 48 |
test_fseek_uninit_whence (FILE *stream, long offset) |
| 49 |
{ |
| 50 |
int whence; |
| 51 |
return fseek (stream, offset, whence); /* { dg-warning "use of uninitialized value 'whence'" } */ |
| 52 |
} |