Debian Codegraph @

clang/test/Modules/same-decl-in-different-modules.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o %t/mod1.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-module-interface -o %t/mod2.pcm
7 // RUN: %clang_cc1 -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -verify
8
9 //--- mod1.cppm
10 export module mod1;
11 export int v;
12 export void func();
13 export class A {};
14 export template <class C>
15 struct S {};
16
17 //--- mod2.cppm
18 export module mod2;
19 export int v;
20 export void func();
21 export class A;
22 export template <class C>
23 struct S {};
24
25 //--- test.cc
26 import mod1;
27 import mod2;
28 void test() {
29 int value = v;
30 func();
31 A a;
32 S<int> s;
33 }
34
35 // [email protected]:* {{declaration 'v' attached to named module 'mod1' cannot be attached to other modules}}
36 // [email protected]:* {{}}
37 // [email protected]:* {{declaration 'func' attached to named module 'mod1' cannot be attached to other modules}}
38 // [email protected]:* {{}}
39 // [email protected]:* {{declaration 'A' attached to named module 'mod1' cannot be attached to other modules}}
40 // [email protected]:* {{}}
41 // [email protected]:* 1+{{declaration 'S' attached to named module 'mod1' cannot be attached to other modules}}
42 // [email protected]:* 1+{{}}