Debian Codegraph @

clang/test/Modules/named-modules-adl-3.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: cd %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -emit-module-interface \
7 // RUN: -o %t/b.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/c.cppm -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \
9 // RUN: -fsyntax-only -verify
10 //
11 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/a.cppm -emit-module-interface -o %t/a.pcm
12 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/b.cppm -fmodule-file=a=%t/a.pcm \
13 // RUN: -emit-module-interface -o %t/b.pcm
14 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/c.cppm -fmodule-file=a=%t/a.pcm \
15 // RUN: -fmodule-file=b=%t/b.pcm -fsyntax-only -verify
16
17 // Test again with reduced BMI.
18 //
19 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
20 // RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -emit-reduced-module-interface \
21 // RUN: -o %t/b.pcm
22 // RUN: %clang_cc1 -std=c++20 %t/c.cppm -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \
23 // RUN: -fsyntax-only -verify
24 //
25 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
26 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/b.cppm -fmodule-file=a=%t/a.pcm \
27 // RUN: -emit-reduced-module-interface -o %t/b.pcm
28 // RUN: %clang_cc1 -std=c++20 -DEXPORT_OPERATOR %t/c.cppm -fmodule-file=a=%t/a.pcm \
29 // RUN: -fmodule-file=b=%t/b.pcm -fsyntax-only -verify
30
31 //--- foo.h
32 namespace n {
33
34 struct s { };
35
36 void operator+(s, int) {}
37
38 } // namespace n
39
40 //--- a.cppm
41 module;
42 #include "foo.h"
43 export module a;
44 export namespace n {
45 using n::s;
46 #ifdef EXPORT_OPERATOR
47 using n::operator+;
48 #endif
49 }
50
51 //--- b.cppm
52 export module b;
53 export import a;
54
55 export template<typename T>
56 void b(T x) {
57 n::s() + x;
58 }
59
60 //--- c.cppm
61 module;
62 #ifdef EXPORT_OPERATOR
63 // expected-no-diagnostics
64 #endif
65 export module c;
66 import b;
67
68 void c(int x) {
69 #ifndef EXPORT_OPERATOR
70 // [email protected]:6 {{invalid operands to binary expression ('n::s' and 'int')}}
71 // expected-note@+2 {{in instantiation of function template specialization 'b<int>' requested here}}
72 #endif
73 b(0);
74
75 #ifndef EXPORT_OPERATOR
76 // expected-error@+2 {{invalid operands to binary expression ('n::s' and 'int')}}
77 #endif
78 n::s() + x;
79 }