1 | // RUN: rm -rf %t |
2 | // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS |
3 | // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify |
4 | // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %s -verify |
5 | // |
6 | // Test both with and without the declarations that refer to unimported |
7 | // entities. For error recovery, those cases implicitly trigger an import. |
8 | |
9 | #include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}} |
10 | |
11 | #ifdef MODULE_H_MACRO |
12 | # error MODULE_H_MACRO should have been hidden |
13 | #endif |
14 | |
15 | #ifdef DEPENDS_ON_MODULE |
16 | # error DEPENDS_ON_MODULE should have been hidden |
17 | #endif |
18 | |
19 | #ifdef ERRORS |
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 {{previous}} |
22 | #else |
23 | #import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}} |
24 | #endif |
25 | Module *mod2; |
26 | |
27 | int getDependsOther() { return depends_on_module_other; } |
28 | |
29 | void testSubframeworkOther() { |
30 | #ifdef ERRORS |
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 {{previous}} |
33 | #endif |
34 | } |
35 | |
36 | // Test umbrella-less submodule includes |
37 | #include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}} |
38 | int getNoUmbrellaA() { return no_umbrella_A; } |
39 | |
40 | // Test umbrella-less submodule includes |
41 | #include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}} |
42 | int getNoUmbrellaC() { return no_umbrella_C; } |
43 | |
44 | #ifndef ERRORS |
45 | // Test header cross-subframework include pattern. |
46 | #include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}} |
47 | #endif |
48 | |
49 | void testSubframeworkOtherAgain() { |
50 | double *sfo1 = sub_framework_other; |
51 | } |
52 | |
53 | void testModuleSubFramework() { |
54 | char *msf = module_subframework; |
55 | } |
56 | |
57 | #include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}} |
58 | |
59 | void testModuleSubFrameworkAgain() { |
60 | char *msf = module_subframework; |
61 | } |
62 | |
63 | // Test inclusion of private headers. |
64 | #include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}} |
65 | |
66 | int getDependsOnModulePrivate() { return depends_on_module_private; } |
67 | |
68 | #include <Module/ModulePrivate.h> // includes the header |
69 | |
70 | int getModulePrivate() { return module_private; } |
71 | |
72 | #include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}} |
73 | int getNoUmbrellaAPrivate() { return no_umbrella_A_private; } |
74 | |
75 | int getNoUmbrellaBPrivateFail() { 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 {{previous}} |
77 | |
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-warning{{treating #include as an import of module 'Module.NotInModule'}} \ |
81 | // expected-warning{{missing submodule 'Module.NotInModule'}} |
82 | |
83 | int getNotInModule() { |
84 | return not_in_module; |
85 | } |
86 | |
87 | void includeNotAtTopLevel() { // expected-note {{function 'includeNotAtTopLevel' begins here}} |
88 | #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ |
89 | expected-error {{redundant #include of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}} |
90 | } |
91 | |
92 | #ifdef __cplusplus |
93 | namespace NS { // expected-note {{begins here}} |
94 | #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ |
95 | expected-error {{redundant #include of module 'NoUmbrella.A' appears within namespace 'NS'}} |
96 | } |
97 | extern "C" { // expected-note {{begins here}} |
98 | #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ |
99 | expected-error {{import of C++ module 'NoUmbrella.A' appears within extern "C"}} |
100 | } |
101 | #endif |
102 | |