1 // RUN: rm -rf %t 2 // RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DERRORS 3 // RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify 4 // 5 // Test both with and without the declarations that refer to unimported 6 // entities. For error recovery, those cases implicitly trigger an import. 7 8 #include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}} 9 10 #ifdef MODULE_H_MACRO 11 # error MODULE_H_MACRO should have been hidden 12 #endif 13 14 #ifdef DEPENDS_ON_MODULE 15 # error DEPENDS_ON_MODULE should have been hidden 16 #endif 17 18 #ifdef ERRORS 19 Module *mod; // expected-error{{declaration of 'Module' must be imported from module 'Module' before it is required}} 20 // expected-note@Inputs/Module.framework/Headers/Module.h:15 {{previous}} 21 #else 22 #import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}} 23 #endif 24 Module *mod2; 25 26 int getDependsOther() { return depends_on_module_other; } 27 28 void testSubframeworkOther() { 29 #ifdef ERRORS 30 double *sfo1 = sub_framework_other; // expected-error{{declaration of 'sub_framework_other' must be imported from module 'DependsOnModule.SubFramework.Other'}} 31 // expected-note@Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h:15 {{previous}} 32 #endif 33 } 34 35 // Test umbrella-less submodule includes 36 #include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}} 37 int getNoUmbrellaA() { return no_umbrella_A; } 38 39 // Test umbrella-less submodule includes 40 #include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}} 41 int getNoUmbrellaC() { return no_umbrella_C; } 42 43 #ifndef ERRORS 44 // Test header cross-subframework include pattern. 45 #include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}} 46 #endif 47 48 void testSubframeworkOtherAgain() { 49 double *sfo1 = sub_framework_other; 50 } 51 52 void testModuleSubFramework() { 53 char *msf = module_subframework; 54 } 55 56 #include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}} 57 58 void testModuleSubFrameworkAgain() { 59 char *msf = module_subframework; 60 } 61 62 // Test inclusion of private headers. 63 #include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}} 64 65 int getDependsOnModulePrivate() { return depends_on_module_private; } 66 67 #include <Module/ModulePrivate.h> // includes the header 68 69 int getModulePrivate() { return module_private; } 70 71 #include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}} 72 int getNoUmbrellaAPrivate() { return no_umbrella_A_private; } 73 74 int getNoUmbrellaBPrivateFail() { return no_umbrella_B_private; } // expected-error{{declaration of 'no_umbrella_B_private' must be imported from module 'NoUmbrella.Private.B_Private'}} 75 // expected-note@Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h:1 {{previous}} 76 77 // Test inclusion of headers that are under an umbrella directory but 78 // not actually part of the module. 79 #include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \ 80 // expected-warning{{missing submodule 'Module.NotInModule'}} 81 82 int getNotInModule() { 83 return not_in_module; 84 } 85 86 void includeNotAtTopLevel() { // expected-note {{to match this '{'}} 87 #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} expected-error {{expected '}'}} 88 } // expected-error {{extraneous closing brace}} 89