summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/ModuleMap.cpp4
-rw-r--r--clang/test/VFS/Inputs/Nonmodular/A.h1
-rw-r--r--clang/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap5
-rw-r--r--clang/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml34
-rw-r--r--clang/test/VFS/Inputs/Nonmodular/test.c3
-rw-r--r--clang/test/VFS/Inputs/Nonmodular/umbrella.h5
-rw-r--r--clang/test/VFS/test_nonmodular.c11
7 files changed, 62 insertions, 1 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 50eb6f82c27..4b49083bbb6 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -297,7 +297,9 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
if (LangOpts.ModulesStrictDeclUse) {
Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
<< RequestingModule->getFullModuleName() << Filename;
- } else if (RequestingModule && RequestingModuleIsModuleInterface) {
+ } else if (RequestingModule && RequestingModuleIsModuleInterface &&
+ LangOpts.isCompilingModule()) {
+ // Do not diagnose when we are not compiling a module.
diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
diag::warn_non_modular_include_in_framework_module :
diag::warn_non_modular_include_in_module;
diff --git a/clang/test/VFS/Inputs/Nonmodular/A.h b/clang/test/VFS/Inputs/Nonmodular/A.h
new file mode 100644
index 00000000000..975f1f0437b
--- /dev/null
+++ b/clang/test/VFS/Inputs/Nonmodular/A.h
@@ -0,0 +1 @@
+// A.h
diff --git a/clang/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap b/clang/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
new file mode 100644
index 00000000000..91f16902d53
--- /dev/null
+++ b/clang/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
@@ -0,0 +1,5 @@
+framework module Nonmodular [extern_c] {
+ umbrella header "umbrella.h"
+ export *
+ module * { export * }
+}
diff --git a/clang/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml b/clang/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
new file mode 100644
index 00000000000..a0417287522
--- /dev/null
+++ b/clang/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
@@ -0,0 +1,34 @@
+{
+ 'version': 0,
+ 'case-sensitive': 'false',
+ 'ignore-non-existent-contents': 'true',
+ 'roots': [
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Nonmodular.framework/Headers",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "umbrella.h",
+ 'external-contents': "IN_DIR/Inputs/Nonmodular/umbrella.h"
+ },
+ {
+ 'type': 'file',
+ 'name': "A.h",
+ 'external-contents': "IN_DIR/Inputs/Nonmodular/A.h"
+ }
+ ]
+ },
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Nonmodular.framework/Modules",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "module.modulemap",
+ 'external-contents': "OUT_DIR/module.modulemap"
+ }
+ ]
+ }
+ ]
+}
diff --git a/clang/test/VFS/Inputs/Nonmodular/test.c b/clang/test/VFS/Inputs/Nonmodular/test.c
new file mode 100644
index 00000000000..62807d0264b
--- /dev/null
+++ b/clang/test/VFS/Inputs/Nonmodular/test.c
@@ -0,0 +1,3 @@
+// expected-no-diagnostics
+
+#include "umbrella.h"
diff --git a/clang/test/VFS/Inputs/Nonmodular/umbrella.h b/clang/test/VFS/Inputs/Nonmodular/umbrella.h
new file mode 100644
index 00000000000..bb79a62ec0c
--- /dev/null
+++ b/clang/test/VFS/Inputs/Nonmodular/umbrella.h
@@ -0,0 +1,5 @@
+#ifndef __umbrella_h__
+#define __umbrella_h__
+
+#include <Nonmodular/A.h>
+#endif
diff --git a/clang/test/VFS/test_nonmodular.c b/clang/test/VFS/test_nonmodular.c
new file mode 100644
index 00000000000..cff4de75186
--- /dev/null
+++ b/clang/test/VFS/test_nonmodular.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/vdir %t/cache %t/outdir
+// We can't have module.map inside Inputs/Nonmodular.
+// RUN: cp %S/Inputs/Nonmodular/Nonmodular.modulemap %t/outdir/module.modulemap
+//
+// RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:IN_DIR:%S:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/Nonmodular/nonmodular-headers.yaml > %t/vdir/nonmodular-headers.yaml
+// RUN: %clang_cc1 -fmodule-name=Nonmodular -fmodules -Wnon-modular-include-in-framework-module -verify -fimplicit-module-maps -fmodules-cache-path=%t/cache -ivfsoverlay %t/vdir/nonmodular-headers.yaml -I %S/Inputs -F %t/vdir -fsyntax-only %S/Inputs/Nonmodular/test.c
+
+// expected-no-diagnostics
OpenPOWER on IntegriCloud