aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticLexKinds.td2
-rw-r--r--include/clang/Lex/Preprocessor.h9
-rw-r--r--lib/Frontend/DependencyFile.cpp10
-rw-r--r--lib/Lex/PPDirectives.cpp3
-rw-r--r--lib/Lex/Pragma.cpp3
-rw-r--r--test/Misc/warning-flags.c3
-rw-r--r--test/Preprocessor/missing-system-header.c2
-rw-r--r--test/Preprocessor/missing-system-header.h2
8 files changed, 21 insertions, 13 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td
index d40e2cde03..275e8a1e28 100644
--- a/include/clang/Basic/DiagnosticLexKinds.td
+++ b/include/clang/Basic/DiagnosticLexKinds.td
@@ -186,7 +186,7 @@ def ext_empty_fnmacro_arg : Extension<
def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
def err_pp_hash_error : Error<"#error%0">;
-def warn_pp_file_not_found : Warning<"'%0' file not found">, DefaultFatal;
+def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
def err_pp_error_opening_file : Error<
"error opening file '%0': %1">, DefaultFatal;
def err_pp_empty_filename : Error<"empty filename">;
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index b14c7e8382..c3557a5e93 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -105,6 +105,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
// State that is set before the preprocessor begins.
bool KeepComments : 1;
bool KeepMacroComments : 1;
+ bool SuppressIncludeNotFoundError : 1;
// State that changes while the preprocessor runs:
bool InMacroArgs : 1; // True if parsing fn macro invocation args.
@@ -344,6 +345,14 @@ public:
bool getCommentRetentionState() const { return KeepComments; }
+ void SetSuppressIncludeNotFoundError(bool Suppress) {
+ SuppressIncludeNotFoundError = Suppress;
+ }
+
+ bool GetSuppressIncludeNotFoundError() {
+ return SuppressIncludeNotFoundError;
+ }
+
/// isCurrentLexer - Return true if we are lexing directly from the specified
/// lexer.
bool isCurrentLexer(const PreprocessorLexer *L) const {
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index 8435864378..db43ab9bbe 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -86,14 +86,8 @@ void clang::AttachDependencyFileGen(Preprocessor &PP,
}
// Disable the "file not found" diagnostic if the -MG option was given.
- // FIXME: Ideally this would live in the driver, but we don't have the ability
- // to remap individual diagnostics there without creating a DiagGroup, in
- // which case we would need to prevent the group name from showing up in
- // diagnostics.
- if (Opts.AddMissingHeaderDeps) {
- PP.getDiagnostics().setDiagnosticMapping(diag::warn_pp_file_not_found,
- diag::MAP_IGNORE, SourceLocation());
- }
+ if (Opts.AddMissingHeaderDeps)
+ PP.SetSuppressIncludeNotFoundError(true);
PP.addPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
}
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 39a358d976..99383e4791 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1187,7 +1187,8 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
End, SearchPath, RelativePath);
if (File == 0) {
- Diag(FilenameTok, diag::warn_pp_file_not_found) << Filename;
+ if (!SuppressIncludeNotFoundError)
+ Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
return;
}
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 1d0b5e4f2d..92c0dd5320 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -368,7 +368,8 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
const DirectoryLookup *CurDir;
const FileEntry *File = LookupFile(Filename, isAngled, 0, CurDir, NULL, NULL);
if (File == 0) {
- Diag(FilenameTok, diag::warn_pp_file_not_found) << Filename;
+ if (!SuppressIncludeNotFoundError)
+ Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
return;
}
diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c
index e29fbeadf9..a911cbb27e 100644
--- a/test/Misc/warning-flags.c
+++ b/test/Misc/warning-flags.c
@@ -17,7 +17,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (313):
+CHECK: Warnings without flags (312):
CHECK-NEXT: auto_storage_class
CHECK-NEXT: backslash_newline_space
CHECK-NEXT: charize_microsoft_ext
@@ -253,7 +253,6 @@ CHECK-NEXT: warn_pointer_attribute_wrong_type
CHECK-NEXT: warn_pp_convert_lhs_to_positive
CHECK-NEXT: warn_pp_convert_rhs_to_positive
CHECK-NEXT: warn_pp_expr_overflow
-CHECK-NEXT: warn_pp_file_not_found
CHECK-NEXT: warn_pp_line_decimal
CHECK-NEXT: warn_pragma_align_expected_equal
CHECK-NEXT: warn_pragma_align_invalid_option
diff --git a/test/Preprocessor/missing-system-header.c b/test/Preprocessor/missing-system-header.c
new file mode 100644
index 0000000000..69cb1314ea
--- /dev/null
+++ b/test/Preprocessor/missing-system-header.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+#include "missing-system-header.h"
diff --git a/test/Preprocessor/missing-system-header.h b/test/Preprocessor/missing-system-header.h
new file mode 100644
index 0000000000..393ab2b5c9
--- /dev/null
+++ b/test/Preprocessor/missing-system-header.h
@@ -0,0 +1,2 @@
+#pragma clang system_header
+#include "not exist" // expected-error {{file not found}}