2 // RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS
3 // RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify
4 // RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %s -verify
6 // Test both with and without the declarations that refer to unimported
7 // entities. For error recovery, those cases implicitly trigger an import.
9 #include <DependsOnModule/DependsOnModule.h> // expected-remark{{treating #include as an import of module 'DependsOnModule'}}
12 # error MODULE_H_MACRO should have been hidden
15 #ifdef DEPENDS_ON_MODULE
16 # error DEPENDS_ON_MODULE should have been hidden
20 Module *mod; // expected-error{{declaration of 'Module' must be imported from module 'Module' before it is required}}
21 // expected-note@Inputs/Module.framework/Headers/Module.h:15 {{not visible}}
23 #import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-remark{{treating #import as an import of module 'AlsoDependsOnModule'}}
27 int getDependsOther(void) { return depends_on_module_other; }
29 void testSubframeworkOther(void) {
31 double *sfo1 = sub_framework_other; // expected-error{{declaration of 'sub_framework_other' must be imported from module 'DependsOnModule.SubFramework.Other'}}
32 // expected-note@Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h:15 {{not visible}}
36 // Test umbrella-less submodule includes
37 #include <NoUmbrella/A.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.A'}}
38 int getNoUmbrellaA(void) { return no_umbrella_A; }
40 // Test umbrella-less submodule includes
41 #include <NoUmbrella/SubDir/C.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
42 int getNoUmbrellaC(void) { return no_umbrella_C; }
45 // Test header cross-subframework include pattern.
46 #include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
49 void testSubframeworkOtherAgain(void) {
50 double *sfo1 = sub_framework_other;
53 void testModuleSubFramework(void) {
54 char *msf = module_subframework;
57 #include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-remark{{treating #include as an import of module 'Module.SubFramework'}}
59 void testModuleSubFrameworkAgain(void) {
60 char *msf = module_subframework;
63 // Test inclusion of private headers.
64 #include <DependsOnModule/DependsOnModulePrivate.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
66 int getDependsOnModulePrivate(void) { return depends_on_module_private; }
68 #include <Module/ModulePrivate.h> // includes the header
70 int getModulePrivate(void) { return module_private; }
72 #include <NoUmbrella/A_Private.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
73 int getNoUmbrellaAPrivate(void) { return no_umbrella_A_private; }
75 int getNoUmbrellaBPrivateFail(void) { return no_umbrella_B_private; } // expected-error{{declaration of 'no_umbrella_B_private' must be imported from module 'NoUmbrella.Private.B_Private'}}
76 // expected-note@Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h:1 {{not visible}}
78 // Test inclusion of headers that are under an umbrella directory but
79 // not actually part of the module.
80 #include <Module/NotInModule.h> // expected-remark{{treating #include as an import of module 'Module.NotInModule'}} \
81 // expected-warning{{missing submodule 'Module.NotInModule'}}
83 int getNotInModule(void) {
87 void includeNotAtTopLevel(void) { // expected-note {{function 'includeNotAtTopLevel' begins here}}
88 #include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \
89 expected-error {{redundant #include of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}}
93 namespace NS { // expected-note {{begins here}}
94 #include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \
95 expected-error {{redundant #include of module 'NoUmbrella.A' appears within namespace 'NS'}}
97 extern "C" { // expected-note {{begins here}}
98 #include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \
99 expected-error {{import of C++ module 'NoUmbrella.A' appears within extern "C"}}