Clang Project

clang_source_code/test/Modules/friend-definition-2.cpp
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
5module A {}
6#pragma clang module contents
7#pragma clang module begin A
8template<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
13module B {}
14#pragma clang module contents
15#pragma clang module begin B
16template<typename T> struct ct { friend auto operator-(ct, ct) { struct X{}; return X(); } void x(); };
17inline auto f() { return ct<float>() - ct<float>(); }
18#pragma clang module end
19#pragma clang module endbuild
20
21// Force the definition of ct in module A to be the primary definition.
22#pragma clang module import A
23template<typename T> void ct<T>::x() {}
24
25// Attempt to cause the definition of operator- in the ct primary template in
26// module B to be the primary definition of that function. If that happens,
27// we'll be left with a class template ct that appears to not contain a
28// definition of the inline friend function.
29#pragma clang module import B
30auto v = f();
31
32ct<int> make();
33void h() {
34  make() - make();
35}
36