diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 1acaf6862e3a..aa6e1732baea 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -599,15 +599,15 @@ void DumpTokensAction::ExecuteAction() { void GeneratePTHAction::ExecuteAction() { CompilerInstance &CI = getCompilerInstance(); - llvm::raw_fd_ostream *OS = - CI.createDefaultOutputFile(true, getCurrentFile()); - if (!OS) - return; - - if (!OS->supportsSeeking()) { + 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; CacheTokens(CI.getPreprocessor(), OS); } diff --git a/clang/test/PCH/emit-pth.c b/clang/test/PCH/emit-pth.c deleted file mode 100644 index 63144b278e8d..000000000000 --- a/clang/test/PCH/emit-pth.c +++ /dev/null @@ -1,10 +0,0 @@ -// 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! - -// MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for raw_ostream::SupportSeeking. -// REQUIRES: shell