summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erikjv@me.com>2016-10-27 14:17:10 +0000
committerErik Verbruggen <erikjv@me.com>2016-10-27 14:17:10 +0000
commite0bde7554ce04ef7af99c69d526882a56f54a928 (patch)
treea62a277df65a36bb68e905945eadb07a6b4efb70 /clang/lib/Lex/Pragma.cpp
parent7cc713adcb668c23cbac71cfd7f268dd5afb618d (diff)
downloadbcm5719-llvm-e0bde7554ce04ef7af99c69d526882a56f54a928.tar.gz
bcm5719-llvm-e0bde7554ce04ef7af99c69d526882a56f54a928.zip
Do not print include_next/pragma once warnings when input is a header.
r276653 suppressed the pragma once warning when generating a PCH file. This patch extends that to any main file for which clang is told (with the -x option) that it's a header file. It will also suppress the warning "#include_next in primary source file". Differential Revision: http://reviews.llvm.org/D25989 llvm-svn: 285295
Diffstat (limited to 'clang/lib/Lex/Pragma.cpp')
-rw-r--r--clang/lib/Lex/Pragma.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 2c04a2d57c0..100da514144 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -372,8 +372,10 @@ void Preprocessor::HandleMicrosoft__pragma(Token &Tok) {
///
void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
// 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) {
+ // this is a prefix to a TU, which indicates we're generating a PCH file, or
+ // when the main file is a header (e.g. when -xc-header is provided on the
+ // commandline).
+ if (isInPrimaryFile() && TUKind != TU_Prefix && !getLangOpts().IsHeaderFile) {
Diag(OnceTok, diag::pp_pragma_once_in_main_file);
return;
}
OpenPOWER on IntegriCloud