1 // RUN: rm -rf %t 2 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DALLOW_NAME_LEAKAGE 3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s -DIMPORT 4 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fmodule-name=x -I%S/Inputs/submodule-visibility -verify %s 5 // RUN: %clang_cc1 -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s 6 // 7 // Explicit module builds. 8 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -emit-module -x c++-module-map %S/Inputs/submodule-visibility/module.modulemap -fmodule-name=other -o %t/other.pcm 9 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -fmodules-local-submodule-visibility -fmodule-file=%t/other.pcm -verify -fmodule-name=x -I%S/Inputs/submodule-visibility %s 10 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -fmodule-file=%t/other.pcm -verify -fmodule-name=x -I%S/Inputs/submodule-visibility %s -DALLOW_TEXTUAL_NAME_LEAKAGE 11 12 #include "a.h" 13 #include "b.h" 14 15 #if ALLOW_NAME_LEAKAGE 16 // expected-no-diagnostics 17 #elif IMPORT 18 // expected-error@-6 {{could not build module 'x'}} 19 #elif ALLOW_TEXTUAL_NAME_LEAKAGE 20 // expected-warning@b.h:7 {{A is defined}} 21 #else 22 // The use of -fmodule-name=x causes us to textually include the above headers. 23 // The submodule visibility rules are still applied in this case. 24 // 25 // expected-error@b.h:1 {{missing '#include "a.h"'; 'n' must be declared}} 26 // expected-note@a.h:1 {{here}} 27 #endif 28 29 int k = n + m; // OK, a and b are visible here. 30 31 #ifndef A 32 #error A is not defined 33 #endif 34 35 #ifndef B 36 #error B is not defined 37 #endif 38 39 // Ensure we don't compute the linkage of this struct before we find it has a 40 // typedef name for linkage purposes. 41 typedef struct { 42 int p; 43 void (*f)(int p); 44 } name_for_linkage; 45 g()46void g() { b_template<int>(); } 47