summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaType.cpp7
-rw-r--r--clang/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h8
-rw-r--r--clang/test/SemaObjCXX/nullability-consistency.mm4
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index d950d329b4e..b7f5ca058c7 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2791,9 +2791,12 @@ static FileID getNullabilityCompletenessCheckFileID(Sema &S,
// We don't want to perform completeness checks on the main file or in
// system headers.
const SrcMgr::FileInfo &fileInfo = sloc.getFile();
- if (fileInfo.getIncludeLoc().isInvalid() ||
- fileInfo.getFileCharacteristic() != SrcMgr::C_User)
+ if (fileInfo.getIncludeLoc().isInvalid())
return FileID();
+ if (fileInfo.getFileCharacteristic() != SrcMgr::C_User &&
+ S.Diags.getSuppressSystemWarnings()) {
+ return FileID();
+ }
return file;
}
diff --git a/clang/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h b/clang/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
new file mode 100644
index 00000000000..6dbca1663d5
--- /dev/null
+++ b/clang/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
@@ -0,0 +1,8 @@
+// Simply marking this as "#pragma clang system_header" didn't tickle the bug, rdar://problem/21134250.
+
+void system1(int *ptr);
+#if WARN_IN_SYSTEM_HEADERS
+// expected-warning@-2{{pointer is missing a nullability type specifier}}
+#endif
+
+void system2(int * __nonnull);
diff --git a/clang/test/SemaObjCXX/nullability-consistency.mm b/clang/test/SemaObjCXX/nullability-consistency.mm
index 7497e84a366..acb972da0b8 100644
--- a/clang/test/SemaObjCXX/nullability-consistency.mm
+++ b/clang/test/SemaObjCXX/nullability-consistency.mm
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs %s -verify
+// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs -isystem %S/Inputs/nullability-consistency-system %s -verify
+// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs -isystem %S/Inputs/nullability-consistency-system %s -Wsystem-headers -DWARN_IN_SYSTEM_HEADERS -verify
#include "nullability-consistency-1.h"
#include "nullability-consistency-3.h"
@@ -8,6 +9,7 @@
#include "nullability-consistency-6.h"
#include "nullability-consistency-7.h"
#include "nullability-consistency-8.h"
+#include "nullability-consistency-system.h"
void h1(int *ptr) { } // don't warn
OpenPOWER on IntegriCloud