Nico Weber 74989aff53 compiler-rt: Rename cc files below test/sanitizer_common to cpp
See r367803 and similar other changes.

llvm-svn: 367863
2019-08-05 13:57:03 +00:00

21 lines
542 B
C++

// RUN: %clangxx -g %s -o %t && %run %t
#include <assert.h>
#include <stdio.h>
int main(int argc, char **argv) {
FILE *fp = fopen(argv[0], "r");
assert(fp);
// the file should be at least one character long, always
assert(getc_unlocked(fp) != EOF);
// POSIX guarantees being able to ungetc() at least one character
// NB: ungetc_unlocked is apparently not present
assert(ungetc('X', fp) != EOF);
// check whether ungetc() works with getc_unlocked()
assert(getc_unlocked(fp) == 'X');
assert(!fclose(fp));
return 0;
}