Skip to content

Commit f0d7ccc

Browse files
[Modules][NFC] Rewrite friend-definition-2.cpp with split-file (#112380)
Instead of the pragmas, which are less familiar to people. This is a follow-up of a discussion from #111992.
1 parent 3bf2295 commit f0d7ccc

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

clang/test/Modules/friend-definition-2.cpp

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,53 @@
1-
// RUN: %clang_cc1 -std=c++14 -fmodules %s -verify
2-
// RUN: %clang_cc1 -std=c++14 -fmodules %s -verify -triple i686-windows
3-
// expected-no-diagnostics
4-
#pragma clang module build A
5-
module A {}
6-
#pragma clang module contents
7-
#pragma clang module begin A
1+
// RUN: split-file %s %t
2+
3+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=A -emit-module %t/a.modulemap -o %t/a.pcm
4+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=B -emit-module %t/b.modulemap -o %t/b.pcm
5+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap \
6+
// RUN: -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm \
7+
// RUN: %t/use.cc -verify
8+
9+
// RUN: rm -f %t/*.pcm
10+
11+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=A -emit-module %t/a.modulemap -o %t/a.pcm -triple i686-windows
12+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=B -emit-module %t/b.modulemap -o %t/b.pcm -triple i686-windows
13+
// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap \
14+
// RUN: -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm \
15+
// RUN: %t/use.cc -verify -triple i686-windows
16+
17+
//--- a.modulemap
18+
module A {
19+
header "a.h"
20+
}
21+
22+
//--- a.h
23+
#ifndef A_H
24+
#define A_H
25+
template<typename T> struct ct { friend auto operator-(ct, ct) { struct X {}; return X(); } void x(); };
26+
#endif
27+
28+
//--- b.modulemap
29+
module B {
30+
header "b.h"
31+
}
32+
33+
//--- b.h
34+
#ifndef B_H
35+
#define B_H
836
template<typename T> struct ct { friend auto operator-(ct, ct) { struct X {}; return X(); } void x(); };
9-
#pragma clang module end
10-
#pragma clang module endbuild
11-
12-
#pragma clang module build B
13-
module B {}
14-
#pragma clang module contents
15-
#pragma clang module begin B
16-
template<typename T> struct ct { friend auto operator-(ct, ct) { struct X{}; return X(); } void x(); };
1737
inline auto f() { return ct<float>() - ct<float>(); }
18-
#pragma clang module end
19-
#pragma clang module endbuild
38+
#endif
2039

40+
//--- use.cc
41+
// expected-no-diagnostics
2142
// Force the definition of ct in module A to be the primary definition.
22-
#pragma clang module import A
43+
#include "a.h"
2344
template<typename T> void ct<T>::x() {}
2445

2546
// Attempt to cause the definition of operator- in the ct primary template in
2647
// module B to be the primary definition of that function. If that happens,
2748
// we'll be left with a class template ct that appears to not contain a
2849
// definition of the inline friend function.
29-
#pragma clang module import B
50+
#include "b.h"
3051
auto v = f();
3152

3253
ct<int> make();

0 commit comments

Comments
 (0)