2011-09-16 06:00:41 +08:00
|
|
|
// RUN: rm -rf %t
|
2017-12-22 10:53:30 +08:00
|
|
|
// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS
|
|
|
|
// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify
|
|
|
|
// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %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}}
|
2020-04-29 09:22:34 +08:00
|
|
|
// expected-note@Inputs/Module.framework/Headers/Module.h:15 {{not visible}}
|
2013-08-21 04:35:18 +08:00
|
|
|
#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'}}
|
2020-04-29 09:22:34 +08:00
|
|
|
// expected-note@Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h:15 {{not visible}}
|
2013-08-21 04:35:18 +08:00
|
|
|
#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'}}
|
2020-04-29 09:22:34 +08:00
|
|
|
// expected-note@Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h:1 {{not visible}}
|
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
|
|
|
|
2015-09-19 13:32:57 +08:00
|
|
|
void includeNotAtTopLevel() { // expected-note {{function 'includeNotAtTopLevel' begins here}}
|
|
|
|
#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \
|
2015-11-18 07:32:01 +08:00
|
|
|
expected-error {{redundant #include of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}}
|
2015-09-19 13:32:57 +08:00
|
|
|
}
|
2015-11-18 07:32:01 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
namespace NS { // expected-note {{begins here}}
|
|
|
|
#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \
|
|
|
|
expected-error {{redundant #include of module 'NoUmbrella.A' appears within namespace 'NS'}}
|
|
|
|
}
|
|
|
|
extern "C" { // expected-note {{begins here}}
|
|
|
|
#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \
|
|
|
|
expected-error {{import of C++ module 'NoUmbrella.A' appears within extern "C"}}
|
|
|
|
}
|
|
|
|
#endif
|