blob: 23bb63b924e1ecac8e9dd834ad5db06f8aa4afdd [file] [log] [blame]
Douglas Gregor97eec242011-09-15 22:00:41 +00001// RUN: rm -rf %t
Richard Smithe156254d2013-08-20 20:35:18 +00002// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DERRORS
Douglas Gregor35b04d62013-02-07 19:01:24 +00003// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify
Richard Smithe156254d2013-08-20 20:35:18 +00004//
5// Test both with and without the declarations that refer to unimported
6// entities. For error recovery, those cases implicitly trigger an import.
Douglas Gregor97eec242011-09-15 22:00:41 +00007
Douglas Gregor41e115a2011-11-30 18:02:36 +00008#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}}
Douglas Gregor97eec242011-09-15 22:00:41 +00009
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
Douglas Gregorcf68c582011-12-01 22:20:10 +000017
Richard Smithe156254d2013-08-20 20:35:18 +000018#ifdef ERRORS
19Module *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
Douglas Gregord8bd7532011-12-05 17:40:25 +000022#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
Richard Smithe156254d2013-08-20 20:35:18 +000023#endif
Douglas Gregord8bd7532011-12-05 17:40:25 +000024Module *mod2;
25
Douglas Gregore5626c42011-12-06 17:15:11 +000026int getDependsOther() { return depends_on_module_other; }
Douglas Gregor356f3d42011-12-06 17:31:28 +000027
28void testSubframeworkOther() {
Richard Smithe156254d2013-08-20 20:35:18 +000029#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
Douglas Gregor356f3d42011-12-06 17:31:28 +000033}
34
Douglas Gregor70331272011-12-09 02:04:43 +000035// Test umbrella-less submodule includes
36#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}}
37int getNoUmbrellaA() { return no_umbrella_A; }
38
Douglas Gregorc1aaf8c2011-12-12 19:13:53 +000039// Test umbrella-less submodule includes
40#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
41int getNoUmbrellaC() { return no_umbrella_C; }
42
Richard Smithe156254d2013-08-20 20:35:18 +000043#ifndef ERRORS
Douglas Gregor356f3d42011-12-06 17:31:28 +000044// Test header cross-subframework include pattern.
Douglas Gregordd005f62011-12-06 17:34:58 +000045#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
Richard Smithe156254d2013-08-20 20:35:18 +000046#endif
Douglas Gregor356f3d42011-12-06 17:31:28 +000047
48void testSubframeworkOtherAgain() {
49 double *sfo1 = sub_framework_other;
50}
Douglas Gregore89dbc12011-12-06 19:39:29 +000051
52void 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
58void testModuleSubFrameworkAgain() {
59 char *msf = module_subframework;
60}
Douglas Gregore7ab3662011-12-07 02:23:45 +000061
62// Test inclusion of private headers.
63#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
Douglas Gregor80306772011-12-07 21:25:07 +000064
65int getDependsOnModulePrivate() { return depends_on_module_private; }
Douglas Gregor9458f822011-12-07 22:05:21 +000066
Douglas Gregor09a22f02012-01-13 16:54:27 +000067#include <Module/ModulePrivate.h> // includes the header
Douglas Gregor9458f822011-12-07 22:05:21 +000068
69int getModulePrivate() { return module_private; }
Douglas Gregor70331272011-12-09 02:04:43 +000070
71#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
72int getNoUmbrellaAPrivate() { return no_umbrella_A_private; }
73
Richard Smithe156254d2013-08-20 20:35:18 +000074int 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}}
Douglas Gregor98a52db2011-12-20 00:28:52 +000076
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
82int getNotInModule() {
83 return not_in_module;
84}