Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / getc_unlocked.cpp
blobc4257d130428576c2cf4952d12464f8873086189
1 // RUN: %clangxx -g %s -o %t && %run %t
3 #include <assert.h>
4 #include <stdio.h>
6 int main(int argc, char **argv) {
7 FILE *fp = fopen(argv[0], "r");
8 assert(fp);
10 // the file should be at least one character long, always
11 assert(getc_unlocked(fp) != EOF);
12 // POSIX guarantees being able to ungetc() at least one character
13 // NB: ungetc_unlocked is apparently not present
14 assert(ungetc('X', fp) != EOF);
15 // check whether ungetc() works with getc_unlocked()
16 assert(getc_unlocked(fp) == 'X');
18 assert(!fclose(fp));
19 return 0;