summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
authorSunil Srivastava <sunil_srivastava@playstation.sony.com>2016-07-25 17:17:06 +0000
committerSunil Srivastava <sunil_srivastava@playstation.sony.com>2016-07-25 17:17:06 +0000
commitfe58327146b212433f9d015c1f6d60d076ad8475 (patch)
tree5bb11c2f647257bb3d0b3f4cdfeded1eeb78c590 /clang/lib/Lex/Pragma.cpp
parent0cdbe7a57235dd76f8fcb8a8d990a078b025ca27 (diff)
downloadbcm5719-llvm-fe58327146b212433f9d015c1f6d60d076ad8475.tar.gz
bcm5719-llvm-fe58327146b212433f9d015c1f6d60d076ad8475.zip
Support '#pragma once' in headers when using PCH
The '#pragma once' directive was erroneously ignored when encountered in the header-file specified in generate-PCH-mode. This resulted in compile-time errors in some cases with legal code, and also a misleading warning being produced. Patch by Warren Ristow! Differential Revision: http://reviews.llvm.org/D19815 llvm-svn: 276653
Diffstat (limited to 'clang/lib/Lex/Pragma.cpp')
-rw-r--r--clang/lib/Lex/Pragma.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index d6e651727cc..1ce4b4391f6 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -352,7 +352,9 @@ void Preprocessor::HandleMicrosoft__pragma(Token &Tok) {
/// HandlePragmaOnce - Handle \#pragma once. OnceTok is the 'once'.
///
void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
- if (isInPrimaryFile()) {
+ // Don't honor the 'once' when handling the primary source file, unless
+ // this is a prefix to a TU, which indicates we're generating a PCH file.
+ if (isInPrimaryFile() && TUKind != TU_Prefix) {
Diag(OnceTok, diag::pp_pragma_once_in_main_file);
return;
}
OpenPOWER on IntegriCloud