102 lines · plain
1// RUN: rm -rf %t2// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS3// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify4// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %s -verify5// 6// Test both with and without the declarations that refer to unimported7// entities. For error recovery, those cases implicitly trigger an import.8 9#include <DependsOnModule/DependsOnModule.h> // expected-remark{{treating #include as an import of module 'DependsOnModule'}}10 11#ifdef MODULE_H_MACRO12# error MODULE_H_MACRO should have been hidden13#endif14 15#ifdef DEPENDS_ON_MODULE16# error DEPENDS_ON_MODULE should have been hidden17#endif18 19#ifdef ERRORS20Module *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 {{not visible}}22#else23#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-remark{{treating #import as an import of module 'AlsoDependsOnModule'}}24#endif25Module *mod2;26 27int getDependsOther(void) { return depends_on_module_other; }28 29void testSubframeworkOther(void) {30#ifdef ERRORS31 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 {{not visible}}33#endif34}35 36// Test umbrella-less submodule includes37#include <NoUmbrella/A.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.A'}}38int getNoUmbrellaA(void) { return no_umbrella_A; } 39 40// Test umbrella-less submodule includes41#include <NoUmbrella/SubDir/C.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}42int getNoUmbrellaC(void) { return no_umbrella_C; } 43 44#ifndef ERRORS45// Test header cross-subframework include pattern.46#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}47#endif48 49void testSubframeworkOtherAgain(void) {50 double *sfo1 = sub_framework_other;51}52 53void testModuleSubFramework(void) {54 char *msf = module_subframework;55}56 57#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-remark{{treating #include as an import of module 'Module.SubFramework'}}58 59void testModuleSubFrameworkAgain(void) {60 char *msf = module_subframework;61}62 63// Test inclusion of private headers.64#include <DependsOnModule/DependsOnModulePrivate.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}65 66int getDependsOnModulePrivate(void) { return depends_on_module_private; }67 68#include <Module/ModulePrivate.h> // includes the header69 70int getModulePrivate(void) { return module_private; }71 72#include <NoUmbrella/A_Private.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}73int getNoUmbrellaAPrivate(void) { return no_umbrella_A_private; }74 75int getNoUmbrellaBPrivateFail(void) { 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 {{not visible}}77 78// Test inclusion of headers that are under an umbrella directory but79// not actually part of the module.80#include <Module/NotInModule.h> // expected-remark{{treating #include as an import of module 'Module.NotInModule'}} \81 // expected-warning{{missing submodule 'Module.NotInModule'}}82 83int getNotInModule(void) {84 return not_in_module;85}86 87void includeNotAtTopLevel(void) { // expected-note {{function 'includeNotAtTopLevel' begins here}}88 #include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \89 expected-error {{redundant #include of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}}90}91 92#ifdef __cplusplus93namespace NS { // expected-note {{begins here}}94#include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \95 expected-error {{redundant #include of module 'NoUmbrella.A' appears within namespace 'NS'}}96}97extern "C" { // expected-note {{begins here}}98#include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \99 expected-error {{import of C++ module 'NoUmbrella.A' appears within extern "C"}}100}101#endif102