void GeneratePTHAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
- if (CI.getFrontendOpts().OutputFile.empty() ||
- CI.getFrontendOpts().OutputFile == "-") {
- // FIXME: Don't fail this way.
- // FIXME: Verify that we can actually seek in the given file.
- llvm::report_fatal_error("PTH requires a seekable file for output!");
- }
llvm::raw_fd_ostream *OS = CI.createDefaultOutputFile(true, getCurrentFile());
if (!OS)
return;
+ if (!OS->supportsSeeking()) {
+ // FIXME: Don't fail this way.
+ llvm::report_fatal_error("PTH requires a seekable file for output!");
+ }
+
CacheTokens(CI.getPreprocessor(), OS);
}
--- /dev/null
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t1 %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o - %s > %t2
+// RUN: cmp %t1 %t2
+// RUN: not %clang_cc1 -triple i386-unknown-unknown -emit-pth -o - %s 2>&1 | \
+// RUN: FileCheck %s
+
+// CHECK: PTH requires a seekable file for output!