252
|
1 // Verify that the use of a PCH does not accidentally make modules from the PCH
|
|
2 // visible to submodules when using -fmodules-local-submodule-visibility
|
|
3 // and -fmodule-name to trigger a textual include.
|
|
4
|
|
5 // RUN: rm -rf %t
|
|
6 // RUN: split-file %s %t
|
|
7
|
|
8 // First check that it works with a header
|
|
9
|
|
10 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
|
|
11 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
|
|
12 // RUN: -fmodule-name=Mod \
|
|
13 // RUN: %t/tu.c -include %t/prefix.h -I %t -verify
|
|
14
|
|
15 // Now with a PCH
|
|
16
|
|
17 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
|
|
18 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
|
|
19 // RUN: -x c-header %t/prefix.h -emit-pch -o %t/prefix.pch -I %t
|
|
20
|
|
21 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
|
|
22 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
|
|
23 // RUN: -fmodule-name=Mod \
|
|
24 // RUN: %t/tu.c -include-pch %t/prefix.pch -I %t -verify
|
|
25
|
|
26 //--- module.modulemap
|
|
27 module ModViaPCH { header "ModViaPCH.h" }
|
|
28 module ModViaInclude { header "ModViaInclude.h" }
|
|
29 module Mod { header "Mod.h" }
|
|
30 module SomeOtherMod { header "SomeOtherMod.h" }
|
|
31
|
|
32 //--- ModViaPCH.h
|
|
33 #define ModViaPCH 1
|
|
34
|
|
35 //--- ModViaInclude.h
|
|
36 #define ModViaInclude 2
|
|
37
|
|
38 //--- SomeOtherMod.h
|
|
39 // empty
|
|
40
|
|
41 //--- Mod.h
|
|
42 #include "SomeOtherMod.h"
|
|
43 #ifdef ModViaPCH
|
|
44 #error "Visibility violation ModViaPCH"
|
|
45 #endif
|
|
46 #ifdef ModViaInclude
|
|
47 #error "Visibility violation ModViaInclude"
|
|
48 #endif
|
|
49
|
|
50 //--- prefix.h
|
|
51 #include "ModViaPCH.h"
|
|
52
|
|
53 //--- tu.c
|
|
54 #include "ModViaInclude.h"
|
|
55 #include "Mod.h"
|
|
56 // expected-no-diagnostics
|