3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 %t/M.cppm -verify
6 // RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-module-interface -o %t/M.pcm
7 // RUN: %clang_cc1 -std=c++20 -fmodule-file=M=%t/M.pcm %t/M.cpp -verify
9 // RUN: %clang_cc1 -std=c++20 -fmodule-file=M=%t/M.pcm %t/user.cpp -verify
12 // expected-no-diagnostics
15 export int external_linkage_var;
16 int module_linkage_var;
17 static int internal_linkage_var;
19 export void external_linkage_fn() {}
20 void module_linkage_fn() {}
21 static void internal_linkage_fn() {}
23 export struct external_linkage_class {};
24 struct module_linkage_class {};
26 struct internal_linkage_class {};
30 external_linkage_fn();
32 internal_linkage_fn();
33 (void)external_linkage_class{};
34 (void)module_linkage_class{};
35 (void)internal_linkage_class{};
36 (void)external_linkage_var;
37 (void)module_linkage_var;
38 (void)internal_linkage_var;
45 void use_from_module_impl() {
46 external_linkage_fn();
48 internal_linkage_fn(); // expected-error {{no matching function for call to 'internal_linkage_fn'}}
49 (void)external_linkage_class{};
50 (void)module_linkage_class{};
51 (void)external_linkage_var;
52 (void)module_linkage_var;
54 // FIXME: Issue #61427 Internal-linkage declarations in the interface TU
55 // should not be not visible here.
56 (void)internal_linkage_class{};
57 (void)internal_linkage_var;
63 void use_from_module_impl() {
64 external_linkage_fn();
65 module_linkage_fn(); // expected-error {{declaration of 'module_linkage_fn' must be imported}}
66 internal_linkage_fn(); // expected-error {{declaration of 'internal_linkage_fn' must be imported}}
67 (void)external_linkage_class{};
68 (void)module_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}}
69 (void)internal_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}}
70 // expected-note@M.cppm:9 {{declaration here is not visible}}
71 // expected-note@M.cppm:10 {{declaration here is not visible}}
72 (void)external_linkage_var;
73 (void)module_linkage_var; // expected-error {{undeclared identifier}}
74 (void)internal_linkage_var; // expected-error {{undeclared identifier}}