252
|
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 //--- foo.h
|
|
18 namespace n {
|
|
19
|
|
20 struct s { };
|
|
21
|
|
22 void operator+(s, int) {}
|
|
23
|
|
24 } // namespace n
|
|
25
|
|
26 //--- a.cppm
|
|
27 module;
|
|
28 #include "foo.h"
|
|
29 export module a;
|
|
30 export namespace n {
|
|
31 using n::s;
|
|
32 #ifdef EXPORT_OPERATOR
|
|
33 using n::operator+;
|
|
34 #endif
|
|
35 }
|
|
36
|
|
37 //--- b.cppm
|
|
38 export module b;
|
|
39 export import a;
|
|
40
|
|
41 export template<typename T>
|
|
42 void b(T x) {
|
|
43 n::s() + x;
|
|
44 }
|
|
45
|
|
46 //--- c.cppm
|
|
47 #ifdef EXPORT_OPERATOR
|
|
48 // expected-no-diagnostics
|
|
49 #endif
|
|
50 export module c;
|
|
51 import b;
|
|
52
|
|
53 void c(int x) {
|
|
54 #ifndef EXPORT_OPERATOR
|
|
55 // expected-error@b.cppm:6 {{invalid operands to binary expression ('n::s' and 'int')}}
|
|
56 // expected-note@+2 {{in instantiation of function template specialization 'b<int>' requested here}}
|
|
57 #endif
|
|
58 b(0);
|
|
59
|
|
60 #ifndef EXPORT_OPERATOR
|
|
61 // expected-error@+2 {{invalid operands to binary expression ('n::s' and 'int')}}
|
|
62 #endif
|
|
63 n::s() + x;
|
|
64 }
|