2011-09-16 06:00:41 +08:00
|
|
|
// RUN: rm -rf %t
|
2013-08-21 04:35:18 +08:00
|
|
|
// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DERRORS
|
2013-02-08 03:01:24 +08:00
|
|
|
// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify
|
2013-08-21 04:35:18 +08:00
|
|
|
//
|
|
|
|
// Test both with and without the declarations that refer to unimported
|
|
|
|
// entities. For error recovery, those cases implicitly trigger an import.
|
2011-09-16 06:00:41 +08:00
|
|
|
|
2011-12-01 02:02:36 +08:00
|
|
|
#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}}
|
2011-09-16 06:00:41 +08:00
|
|
|
|
|
|
|
#ifdef MODULE_H_MACRO
|
|
|
|
# error MODULE_H_MACRO should have been hidden
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEPENDS_ON_MODULE
|
|
|
|
# error DEPENDS_ON_MODULE should have been hidden
|
|
|
|
#endif
|
2011-12-02 06:20:10 +08:00
|
|
|
|
2013-08-21 04:35:18 +08:00
|
|
|
#ifdef ERRORS
|
|
|
|
Module *mod; // expected-error{{declaration of 'Module' must be imported from module 'Module' before it is required}}
|
|
|
|
// expected-note@Inputs/Module.framework/Headers/Module.h:15 {{previous}}
|
|
|
|
#else
|
2011-12-06 01:40:25 +08:00
|
|
|
#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
|
2013-08-21 04:35:18 +08:00
|
|
|
#endif
|
2011-12-06 01:40:25 +08:00
|
|
|
Module *mod2;
|
|
|
|
|
2011-12-07 01:15:11 +08:00
|
|
|
int getDependsOther() { return depends_on_module_other; }
|
2011-12-07 01:31:28 +08:00
|
|
|
|
|
|
|
void testSubframeworkOther() {
|
2013-08-21 04:35:18 +08:00
|
|
|
#ifdef ERRORS
|
|
|
|
double *sfo1 = sub_framework_other; // expected-error{{declaration of 'sub_framework_other' must be imported from module 'DependsOnModule.SubFramework.Other'}}
|
|
|
|
// expected-note@Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h:15 {{previous}}
|
|
|
|
#endif
|
2011-12-07 01:31:28 +08:00
|
|
|
}
|
|
|
|
|
2011-12-09 10:04:43 +08:00
|
|
|
// Test umbrella-less submodule includes
|
|
|
|
#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}}
|
|
|
|
int getNoUmbrellaA() { return no_umbrella_A; }
|
|
|
|
|
2011-12-13 03:13:53 +08:00
|
|
|
// Test umbrella-less submodule includes
|
|
|
|
#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
|
|
|
|
int getNoUmbrellaC() { return no_umbrella_C; }
|
|
|
|
|
2013-08-21 04:35:18 +08:00
|
|
|
#ifndef ERRORS
|
2011-12-07 01:31:28 +08:00
|
|
|
// Test header cross-subframework include pattern.
|
2011-12-07 01:34:58 +08:00
|
|
|
#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
|
2013-08-21 04:35:18 +08:00
|
|
|
#endif
|
2011-12-07 01:31:28 +08:00
|
|
|
|
|
|
|
void testSubframeworkOtherAgain() {
|
|
|
|
double *sfo1 = sub_framework_other;
|
|
|
|
}
|
2011-12-07 03:39:29 +08:00
|
|
|
|
|
|
|
void testModuleSubFramework() {
|
|
|
|
char *msf = module_subframework;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}}
|
|
|
|
|
|
|
|
void testModuleSubFrameworkAgain() {
|
|
|
|
char *msf = module_subframework;
|
|
|
|
}
|
2011-12-07 10:23:45 +08:00
|
|
|
|
|
|
|
// Test inclusion of private headers.
|
|
|
|
#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
|
2011-12-08 05:25:07 +08:00
|
|
|
|
|
|
|
int getDependsOnModulePrivate() { return depends_on_module_private; }
|
2011-12-08 06:05:21 +08:00
|
|
|
|
2012-01-14 00:54:27 +08:00
|
|
|
#include <Module/ModulePrivate.h> // includes the header
|
2011-12-08 06:05:21 +08:00
|
|
|
|
|
|
|
int getModulePrivate() { return module_private; }
|
2011-12-09 10:04:43 +08:00
|
|
|
|
|
|
|
#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
|
|
|
|
int getNoUmbrellaAPrivate() { return no_umbrella_A_private; }
|
|
|
|
|
2013-08-21 04:35:18 +08:00
|
|
|
int getNoUmbrellaBPrivateFail() { return no_umbrella_B_private; } // expected-error{{declaration of 'no_umbrella_B_private' must be imported from module 'NoUmbrella.Private.B_Private'}}
|
|
|
|
// expected-note@Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h:1 {{previous}}
|
2011-12-20 08:28:52 +08:00
|
|
|
|
|
|
|
// Test inclusion of headers that are under an umbrella directory but
|
|
|
|
// not actually part of the module.
|
|
|
|
#include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \
|
|
|
|
// expected-warning{{missing submodule 'Module.NotInModule'}}
|
|
|
|
|
|
|
|
int getNotInModule() {
|
|
|
|
return not_in_module;
|
|
|
|
}
|
2013-11-15 12:24:58 +08:00
|
|
|
|
2013-11-23 12:06:09 +08:00
|
|
|
void includeNotAtTopLevel() { // expected-note {{to match this '{'}}
|
|
|
|
#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} expected-error {{expected '}'}}
|
|
|
|
} // expected-error {{extraneous closing brace}}
|